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, kstars
...
... 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¶
Full (package) name of the blend (
debian-astro)
- short_name¶
Short name of the blend (
astro)
- title¶
Blends title (
Debian Astro)
- prefix¶
Prefix for tasks (
astro)
- tasks¶
Tasklist
- update(cache)¶
Update from cache
- Parameters:
cache –
apt.Cachelike object
This 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.
- property 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 namename – Name of the task
sequence –
strorfilecontaining theDeb822description of the taskbase_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. 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 kstars gravit sunclock xtide
- blend¶
Blend name
- prefix¶
Metapackage prefix
- name¶
Task name
- header¶
Deb822 header
- base_deps¶
Base dependencies
- content¶
Deb822List content of the task
- format_upgraded¶
Trueif the format was upgraded from an older version
- property install¶
Trueif the task is installed as a default package
- property index¶
Trueif the task shall appear in the tasks index in the web senitel
- property is_metapackage¶
Trueif the tasks has a Debian metapackage
- property description¶
Return the formatted long description.
- property summary¶
Return the short description (one line summary).
- property section¶
Return the section of the package.
- property architecture¶
Return the architecture of the package version.
- property tests¶
Return all tests for this task when included in tasksel
- property 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, kstars Suggests: sunclock, xtide Description: Educational astronomy applications Various applications that can be used to teach astronomy. . This is however incomplete.
- 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
- 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 object
Instead 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) kstars: None >>> task += apt.Cache() >>> print(dep.name + ": ", dep.summary) kstars: desktop planetarium, observation planning and telescope control
- 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 kstars 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) kstars gravit >>> for dep in task.suggests: ... print(dep.rawstr) sunclock xtide celestia-gnome | celestia-glut
- 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¶
The type of the dependencies in the Or-group
- property rawstr¶
String representation 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.
- property 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. You can spend endless time experimenting with various configurations of simulated universes. >>> print(dep.summary) Visually stunning gravity simulator
- property rawstr¶
String representation 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.
- property wnpp¶
The WNPP bug number, if available, or None
- property homepage¶
Return the homepage for the package.
- property description¶
Return the formatted long description.
- property 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.