Package dak :: Module find_files
[hide private]
[frames] | no frames]

Source Code for Module dak.find_files

  1  #! /usr/bin/env python3 
  2   
  3  """ 
  4  Display information about files related to a specific source package/version 
  5  Display information about package(s) (suite, version, etc.) 
  6   
  7  @contact: Debian FTP Master <ftpmaster@debian.org> 
  8  @copyright: 2000, 2001, 2002, 2003, 2004, 2005, 2006  James Troup <james@nocrew.org> 
  9  @license: GNU General Public License version 2 or later 
 10   
 11  """ 
 12  # This program is free software; you can redistribute it and/or modify 
 13  # it under the terms of the GNU General Public License as published by 
 14  # the Free Software Foundation; either version 2 of the License, or 
 15  # (at your option) any later version. 
 16   
 17  # This program is distributed in the hope that it will be useful, 
 18  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 19  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 20  # GNU General Public License for more details. 
 21   
 22  # You should have received a copy of the GNU General Public License 
 23  # along with this program; if not, write to the Free Software 
 24  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 25   
 26  ################################################################################ 
 27   
 28  # < mhy> whilst you're here, if you have time to look at and merge 
 29  #        https://salsa.debian.org/ftp-team/dak/-/merge_requests/281 , I'd be 
 30  #        nice to you for at least 5 minutes 
 31  # < Ganneff> ... 
 32  # < Ganneff> 10! 
 33  # < mhy> Done 
 34  # ... 
 35  # < mhy> god I hate dak's argument parsing.  One day far in the future 
 36  #        when I have lots of time, I'm going to rip it all out 
 37  # < Ganneff> and replace it with rust 
 38  # * Ganneff hides 
 39  # < mhy> I'll replace *you* with rust 
 40  # < mhy> oh blast, I didn't even make 10 minutes 
 41   
 42  ################################################################################ 
 43   
 44  import sys 
 45   
 46  import apt_pkg 
 47   
 48  from daklib import utils 
 49  from daklib.config import Config 
 50  from daklib.dbconn import DBConn, DBSource 
 51   
 52  ################################################################################ 
 53   
 54   
55 -def usage(exit_code=0):
56 print( 57 """Usage: dak find-files SOURCE_PACKAGE VERSION 58 Display file paths for files related to SOURCE_PACKAGE at VERSION 59 """ 60 ) 61 sys.exit(exit_code)
62 63 64 ################################################################################ 65 66
67 -def main():
68 cnf = Config() 69 70 Arguments = [("h", "help", "FindFiles::Options::Help")] 71 for i in ["help"]: 72 key = "FindFiles::Options::%s" % i 73 if key not in cnf: 74 cnf[key] = "" 75 76 package_details = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) 77 Options = cnf.subtree("FindFiles::Options") 78 79 if Options["Help"]: 80 usage() 81 82 if len(package_details) != 2: 83 utils.fubar("require source package name and version") 84 85 source, version = package_details 86 87 session = DBConn().session() 88 89 q = session.query(DBSource).filter_by(source=source, version=version) 90 91 pkg = q.first() 92 93 if pkg is None: 94 utils.fubar(f"Source {source} at version {version} does not exist") 95 96 filenames = [] 97 98 # Don't include pool otherwise we have to work out components (which may vary 99 # by archive). The partial path is enough for rsync to match it 100 for binary in pkg.binaries: 101 filenames.append(binary.poolfile.filename) 102 103 for filename in sorted(filenames): 104 print(filename)
105 106 107 ###################################################################################### 108 109 110 if __name__ == "__main__": 111 main() 112