diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-01-13 17:22:27 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-01-13 17:22:27 +0100 |
| commit | 38d602dc83006c51dfe4ed594d691ea9b0679498 (patch) | |
| tree | b7aedfba82c44cad6c3012f879b5d6d7e8ad1425 /apt/cdrom.py | |
| parent | 12cf58d12b969010f3d98b2974d72bbb950b775f (diff) | |
| parent | 614897f798d9f16591fbd29ebe2a6c5674102d2d (diff) | |
| download | python-apt-38d602dc83006c51dfe4ed594d691ea9b0679498.tar.gz | |
* apt/*.py:
- Almost complete cleanup of the code
- Remove inconsistent use of tabs and spaces (Closes: #505443)
- Improved documentation
* apt/debfile.py:
- Drop get*() methods, as they are deprecated and were
never in a stable release
- Make DscSrcPackage working
* apt/gtk/widgets.py:
- Fix the code and document the signals
* Introduce new documentation build with Sphinx
- Contains style Guide (Closes: #481562)
- debian/rules: Build the documentation here
- setup.py: Remove pydoc building and add new docs.
- debian/examples: Include examples from documentation
- debian/python-apt.docs:
+ Change html/ to build/doc/html.
+ Add build/doc/text for the text-only documentation
* setup.py:
- Only create build/data when building, not all the time
- Remove build/mo and build/data on clean -a
* debian/control:
- Remove the Conflicts on python2.3-apt, python2.4-apt, as
they are only needed for oldstable (sarge)
- Build-Depend on python-sphinx (>= 0.5)
* aptsources/distinfo.py:
- Allow @ in mirror urls (Closes: #478171) (LP: #223097)
* Merge Ben Finney's whitespace changes (Closes: #481563)
* Merge Ben Finney's do not use has_key() (Closes: #481878)
* Do not use deprecated form of raise statement (Closes: #494259)
* Add support for PkgRecords.SHA256Hash (Closes: #456113)
Diffstat (limited to 'apt/cdrom.py')
| -rw-r--r-- | apt/cdrom.py | 81 |
1 files changed, 60 insertions, 21 deletions
diff --git a/apt/cdrom.py b/apt/cdrom.py index 9d4b62cb..61250fc4 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -1,14 +1,49 @@ +# cdrom.py - CDROM handling +# +# Copyright (c) 2005 Canonical +# Copyright (c) 2009 Julian Andres Klode <jak@debian.org> +# +# Author: Michael Vogt <michael.vogt@ubuntu.com> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +"""Classes related to cdrom handling.""" +import glob + import apt_pkg -from progress import CdromProgress +from apt.progress import CdromProgress + class Cdrom(object): + """Support for apt-cdrom like features. + + This class has several optional parameters for initialisation, which may + be used to influence the behaviour of the object: + + The optional parameter `progress` is a CdromProgress() subclass, which will + ask for the correct cdrom, etc. If not specified or None, a CdromProgress() + object will be used. + + The optional parameter `mountpoint` may be used to specify an alternative + mountpoint. + + If the optional parameter `nomount` is True, the cdroms will not be + mounted. This is the default behaviour. + """ + def __init__(self, progress=None, mountpoint=None, nomount=True): - """ Support for apt-cdrom like features. - Options: - - progress: optional progress.CdromProgress() subclass - - mountpoint: optional alternative mountpoint - - nomount: do not mess with mount/umount the CD - """ self._cdrom = apt_pkg.GetCdrom() if progress is None: self._progress = CdromProgress() @@ -16,32 +51,36 @@ class Cdrom(object): self._progress = progress # see if we have a alternative mountpoint if mountpoint is not None: - apt_pkg.Config.Set("Acquire::cdrom::mount",mountpoint) + apt_pkg.Config.Set("Acquire::cdrom::mount", mountpoint) # do not mess with mount points by default - if nomount is True: + if nomount: apt_pkg.Config.Set("APT::CDROM::NoMount", "true") else: apt_pkg.Config.Set("APT::CDROM::NoMount", "false") + def add(self): - " add cdrom to the sources.list " + """Add cdrom to the sources.list.""" return self._cdrom.Add(self._progress) + def ident(self): - " identify the cdrom " + """Identify the cdrom.""" (res, ident) = self._cdrom.Ident(self._progress) if res: return ident - return None + @property def inSourcesList(self): - " check if the cdrom is already in the current sources.list " - cdid = self.ident() - if cdid is None: + """Check if the cdrom is already in the current sources.list.""" + cd_id = self.ident() + if cd_id is None: # FIXME: throw exception instead return False - # FIXME: check sources.list.d/ as well - for line in open(apt_pkg.Config.FindFile("Dir::Etc::sourcelist")): - line = line.strip() - if not line.startswith("#") and cdid in line: - return True + # Get a list of files + src = glob.glob(apt_pkg.Config.FindDir("Dir::Etc::sourceparts") + '*') + src.append(apt_pkg.Config.FindFile("Dir::Etc::sourcelist")) + # Check each file + for fname in src: + for line in open(fname): + if not line.lstrip().startswith("#") and cd_id in line: + return True return False - |
