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  import apt_pkg 
 46   
 47  from pathlib import Path 
 48   
 49  from daklib.config import Config 
 50  from daklib.dbconn import DBConn, DBSource 
 51  from daklib import utils 
 52   
 53  ################################################################################ 
 54   
 55   
56 -def usage(exit_code=0):
57 print("""Usage: dak find-files SOURCE_PACKAGE VERSION 58 Display file paths for files related to SOURCE_PACKAGE at VERSION 59 """) 60 sys.exit(exit_code)
61 62 ################################################################################ 63 64
65 -def main():
66 cnf = Config() 67 68 Arguments = [('h', "help", "FindFiles::Options::Help")] 69 for i in ["help"]: 70 key = "FindFiles::Options::%s" % i 71 if key not in cnf: 72 cnf[key] = "" 73 74 package_details = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) 75 Options = cnf.subtree("FindFiles::Options") 76 77 if Options["Help"]: 78 usage() 79 80 if len(package_details) != 2: 81 utils.fubar("require source package name and version") 82 83 source, version = package_details 84 85 session = DBConn().session() 86 87 q = session.query(DBSource).filter_by(source=source, version=version) 88 89 pkg = q.first() 90 91 if pkg is None: 92 utils.fubar(f"Source {source} at version {version} does not exist") 93 94 filenames = [] 95 96 # Don't include pool otherwise we have to work out components (which may vary 97 # by archive). The partial path is enough for rsync to match it 98 for binary in pkg.binaries: 99 filenames.append(binary.poolfile.filename) 100 101 for filename in sorted(filenames): 102 print(filename)
103 104 ###################################################################################### 105 106 107 if __name__ == '__main__': 108 main() 109