11#!/usr/bin/env python
22
3- from __future__ import print_function
3+
44import argparse
55import os
66import sys
7+
78import eups
89
910
1011def linkFiles (dstDir , srcDir , verbose = 0 , force = False ):
11- """Link all the regular files in srcDir into dstDir; mkdir all the directories in srcDir and
12- descend recursively"""
12+ """Link all the regular files in srcDir into dstDir; mkdir all the
13+ directories in srcDir and descend recursively"""
1314
1415 if not os .path .exists (dstDir ):
1516 os .makedirs (dstDir )
@@ -22,40 +23,42 @@ def linkFiles(dstDir, srcDir, verbose=0, force=False):
2223 linkFiles (fullDst , fullSrc , verbose , force )
2324 else :
2425 if verbose > 1 :
25- print ("%s -> %s" % ( fullSrc , fullDst ) )
26+ print (f" { fullSrc } -> { fullDst } " )
2627
2728 if os .path .exists (fullDst ):
2829 if force :
2930 os .unlink (fullDst )
3031 else :
31- print ("%s already exists; use --force to overwrite" % fullDst , file = sys .stderr )
32+ print (f" { fullDst } already exists; use --force to overwrite" , file = sys .stderr )
3233 sys .exit (1 )
3334
3435 os .symlink (fullSrc , fullDst )
3536
3637
3738def main ():
38- parser = argparse .ArgumentParser (description = '''Build a link farm to replace long -I/-L argument lists.
39+ parser = argparse .ArgumentParser (
40+ description = """Build a link farm to replace long -I/-L argument lists.
3941All the bin, include files, and libraries for all the dependencies of the specified product are linked into
4042 linkFarmDir/bin, linkFarmDir/include, or linkFarmDir/lib
4143as appropriate. Note that the setup dependencies are used, so you can say e.g.
4244$ setup pipe_tasks
4345$ setup -r ~/LSST/afw
4446$ makeLinkFarm /tmp/linkFarm pipe_tasks
4547creates a link farm for your current selection of products.
46- ''' )
47- parser .add_argument ('linkFarmDir' , type = str , help = 'The directory to setup as a link farm' )
48- parser .add_argument ('productName' , type = str , help = 'The desired product (must be setup)' )
48+ """
49+ )
50+ parser .add_argument ("linkFarmDir" , type = str , help = "The directory to setup as a link farm" )
51+ parser .add_argument ("productName" , type = str , help = "The desired product (must be setup)" )
4952
50- parser .add_argument (' --force' , '-f' , action = ' store_true' , help = "Force creation of farm even if it exists" )
51- parser .add_argument (' --verbose' , '-v' , action = ' count' , help = "Be chatty" )
53+ parser .add_argument (" --force" , "-f" , action = " store_true" , help = "Force creation of farm even if it exists" )
54+ parser .add_argument (" --verbose" , "-v" , action = " count" , help = "Be chatty" )
5255
5356 args = parser .parse_args ()
5457
5558 linkFarmDir = os .path .abspath (args .linkFarmDir )
5659
5760 if not args .force and os .path .exists (linkFarmDir ):
58- print ("Path %s already exists; use --force to overwrite" % args . linkFarmDir , file = sys .stderr )
61+ print (f "Path { args . linkFarmDir } already exists; use --force to overwrite" , file = sys .stderr )
5962 sys .exit (1 )
6063
6164 #
@@ -67,25 +70,25 @@ creates a link farm for your current selection of products.
6770 os .makedirs (d )
6871
6972 products = {}
70- for productName , versionName , optional , recursionDepth in \
71- eups .getDependencies (args .productName , None , setup = True ):
73+ for productName , versionName , optional , recursionDepth in eups .getDependencies (
74+ args .productName , None , setup = True
75+ ):
7276 if productName in products :
7377 continue
7478
7579 products [productName ] = 1
7680
7781 pd = eups .productDir (productName )
78- if not pd : # no product
82+ if not pd : # no product
7983 continue
8084
8185 binDir = os .path .join (pd , "bin" )
8286 incDir = os .path .join (pd , "include" )
8387 libDir = os .path .join (pd , "lib" )
8488
8589 if args .verbose :
86- if args .verbose > 1 or \
87- os .path .exists (binDir ) or os .path .exists (incDir ) or os .path .exists (libDir ):
88- print ("%-15s %s" % (productName , pd ))
90+ if args .verbose > 1 or os .path .exists (binDir ) or os .path .exists (incDir ) or os .path .exists (libDir ):
91+ print (f"{ productName :<15} { pd } " )
8992
9093 if os .path .exists (binDir ):
9194 fullDstDir = os .path .join (linkFarmDir , "bin" )
@@ -108,7 +111,7 @@ creates a link farm for your current selection of products.
108111 if args .force :
109112 os .unlink (fullDst )
110113 else :
111- print ("%s already exists; use --force to overwrite" % fullDst , file = sys .stderr )
114+ print (f" { fullDst } already exists; use --force to overwrite" , file = sys .stderr )
112115 sys .exit (1 )
113116
114117 os .symlink (fullSrc , fullDst )
0 commit comments