Python module debian.blends¶
A module to handle Debian Pure Blends tasks, modelled after apt.package.
The examples use the following sample tasks file:
>>> sample_task = """Format: https://blends.debian.org/blends/1.1
... Task: Education
... Install: true
... Description: Educational astronomy applications
... Various applications that can be used to teach astronomy.
... .
... This is however incomplete.
...
... Recommends: celestia-gnome | celestia-glut, starplot
...
... Recommends: gravit
... WNPP: 743379
... Homepage: http://gravit.slowchop.com/
... Pkg-Description: Visually stunning gravity simulator
... Gravit is a free, visually stunning gravity simulator.
... .
... You can spend endless time experimenting with various
... configurations of simulated universes.
... Why: Useful package
... Remark: Entered Debian in 2014
...
... Suggests: sunclock, xtide
... """
>>> with open('education', 'w') as fp:
... nbytes = fp.write(sample_task)
-
class
blends.Blend(basedir='.')¶ Representation of a Debian Pure Blend.
-
name= None¶ Full (package) name of the blend (
debian-astro)
-
short_name= None¶ Short name of the blend (
astro)
-
title= None¶ Blends title (
Debian Astro)
-
prefix= None¶ Prefix for tasks (
astro)
-
tasks= None¶ Tasklist
-
update(cache)¶ Update from cache
Parameters: cache – apt.Cachelike objectThis adds the available versions to all dependencies. It updates descriptions, summaries etc. available to all BaseDependencies in all tasks.
Instead of using
update(), also the+=operator can be used.
-
all¶ All Base Dependencies of this task
-
fix_dependencies()¶ Fix the dependencies according to available packages
This lowers all unavailable
recommendeddependencies tosuggested.
-
gen_control()¶ Return the task as list of
Deb822objects suitable fordebian/control
-
gen_task_desc(udeb=False)¶ Return the task as list of
Deb822objects suitable forblends-task.desc
-
-
class
blends.Task(blend, name, sequence, base_deps=None)¶ Representation of a Blends task. Modelled after apt.package.Version.
The Version class contains all information related to a specific package version of a blends task.
Parameters: - blend –
Blendobject, or Blend name - name – Name of the task
- sequence –
strorfilecontaining theDeb822description of the task - base_deps – List of dependencies to add to the task (
str)
When the header does not contain a line
Format: https://blends.debian.org/blends/1.1then the
Dependspriorities will be lowered toRecommendswhen read.Example:
>>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> print(task.name) education >>> print(task.package_name) astro-education >>> print(task.description) Various applications that can be used to teach astronomy. <BLANKLINE> This is however incomplete. >>> print(task.summary) Educational astronomy applications >>> print(task.section) metapackages >>> print(task.architecture) all >>> for p in task.all: ... print(p.name) celestia-gnome celestia-glut starplot gravit sunclock xtide
-
blend= None¶ Blend name
-
prefix= None¶ Metapackage prefix
-
name= None¶ Task name
-
header= None¶ Deb822 header
-
base_deps= None¶ Base dependencies
-
content= None¶ Deb822List content of the task
-
format_upgraded= None¶ Trueif the format was upgraded from an older version
-
install¶ Trueif the task is installed as a default package
-
index¶ Trueif the task shall appear in the tasks index in the web senitel
-
is_metapackage¶ Trueif the tasks has a Debian metapackage
-
description¶ Return the formatted long description.
-
summary¶ Return the short description (one line summary).
-
section¶ Return the section of the package.
-
architecture¶ Return the architecture of the package version.
-
tests¶ Return all tests for this task when included in tasksel
-
all¶ All Base Dependencies of this task
-
gen_control()¶ Return the task as
Deb822object suitable fordebian/control>>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> print(task.gen_control().dump()) Package: astro-education Section: metapackages Architecture: all Recommends: celestia-gnome | celestia-glut, gravit, starplot Suggests: sunclock, xtide Description: Educational astronomy applications Various applications that can be used to teach astronomy. . This is however incomplete. <BLANKLINE>
-
gen_task_desc(udeb=False)¶ Return the task as
Deb822object suitable forblends-task.desc.Parameters: udeb – if True, generate`blends-task.descsuitable for udebs>>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> print(task.gen_task_desc().dump()) Task: astro-education Parent: debian-astro Section: debian-astro Description: Educational astronomy applications Various applications that can be used to teach astronomy. . This is however incomplete. Test-new-install: mark show Key: astro-education <BLANKLINE>
-
update(cache)¶ Update from cache
This adds the available versions to all dependencies. It updates descriptions, summaries etc. available to all BaseDependencies.
Parameters: cache – apt.Cachelike objectInstead of using
update(), also the+=operator can be used:>>> import apt >>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> dep = task.recommends[1][0] >>> print(dep.name + ": ", dep.summary) starplot: None >>> task += apt.Cache() >>> print(dep.name + ": ", dep.summary) starplot: 3-dimensional perspective star map viewer
-
fix_dependencies()¶ Fix the dependencies according to available packages
This lowers all unavailable
recommendeddependencies tosuggested.>>> import apt >>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> for dep in task.recommends: ... print(dep.rawstr) celestia-gnome | celestia-glut starplot gravit >>> for dep in task.suggests: ... print(dep.rawstr) sunclock xtide >>> task += apt.Cache() >>> missing = task.fix_dependencies() >>> for dep in task.recommends: ... print(dep.rawstr) starplot gravit >>> for dep in task.suggests: ... print(dep.rawstr) sunclock xtide celestia-gnome | celestia-glut
- blend –
-
class
blends.Dependency(rawtype, s=None, content=None)¶ Represent an Or-group of dependencies.
Example:
>>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> dep = task.recommends[0] >>> print(dep.rawstr) celestia-gnome | celestia-glut
-
rawtype= None¶ The type of the dependencies in the Or-group
-
rawstr¶ String represenation of the Or-group of dependencies.
Returns the string representation of the Or-group of dependencies as it would be written in the
debian/controlfile. The string representation does not include the type of the Or-group of dependencies.
-
target_versions¶ A list of all Version objects which satisfy this Or-group of deps.
-
-
class
blends.BaseDependency(s, content=None)¶ A single dependency.
Example:
>>> with open('education') as fp: ... task = Task('debian-astro', 'education', fp) >>> dep = task.recommends[2][0] >>> print(dep.rawstr) gravit >>> print(dep.wnpp) 743379 >>> print(dep.homepage) http://gravit.slowchop.com/ >>> print(dep.description) Gravit is a free, visually stunning gravity simulator. <BLANKLINE> You can spend endless time experimenting with various configurations of simulated universes. >>> print(dep.summary) Visually stunning gravity simulator
-
rawstr¶ String represenation of the dependency.
Returns the string representation of the dependency as it would be written in the
debian/controlfile. The string representation does not include the type of the dependency.
-
wnpp¶ The WNPP bug number, if available, or None
-
homepage¶ Return the homepage for the package.
-
description¶ Return the formatted long description.
-
summary¶ Return the short description (one line summary).
-
-
class
blends.Deb822List(paragraphs)¶ A list of
Deb822paragraphs-
dump(fd=None, encoding=None, text_mode=False)¶ Dump the the contents in the original format
If
fdisNone, returns astrobject. Otherwise,fdis assumed to be afile-like object, and this method will write the data to it instead of returning anstrobject.If
fdis notNoneandtext_modeisFalse, the data will be encoded to a byte string before writing to the file. The encoding used is chosen via the encoding parameter; None means to use the encoding the object was initialized with (utf-8 by default). This will raiseUnicodeEncodeErrorif the encoding can’t support all the characters in theDeb822Dictvalues.
-
-
blends.aptcache(release=None, srcdirs=['/etc/blends'])¶ Open and update a (temporary) apt cache for the specified distribution.
Parameters: - release – Distribution name
- srcdirs – List of directories to search for
sources.list.<<release>>
If the distribution is not given, use the system’s cache without update.
-
blends.uddcache(packages, release, components=['main'], **db_args)¶ Create a
dictfrom UDD that is roughly modelled afterapt.Cache.The
dictjust resolves the version number and archs for the packages. For performance reasons, an initial package list needs to be given.Parameters: - release – Distribution name
- packages – Initial package list
- db_args – UDD connection parameters
Provideddependencies are integrated in the returneddict.