Debian Codegraph @

attic/scripts/findatp

raw
1 #!/usr/bin/perl -w
2 ######################################################################
3 ## Time-stamp: <2006/07/18 17:36:06 bruce>
4 ######################################################################
5 ## This is the findatp utility. It is used to find atp files in the
6 ## search path used by programs in the Atoms package.
7 ##
8 ## This program is copyright (c) 2001 Bruce Ravel
9 ## <[email protected]>
10 ## http://cars9.uchicago.edu/~ravel/software/atoms/
11 ##
12 ## -------------------------------------------------------------------
13 ## All rights reserved. This program is free software; you can
14 ## redistribute it and/or modify it under the same terms as Perl
15 ## itself.
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 ## Artistic License for more details.
21 ## -------------------------------------------------------------------
22 ##
23 ######################################################################
24 ## Code:
25
26 ##use lib '/usr/local/share/ifeffit/perl';
27 use Xray::Atoms;
28 use Ifeffit::FindFile;
29
30 my @search_path = (Ifeffit::FindFile->find('other', 'atp_personal'),
31 Ifeffit::FindFile->find('atoms', 'atp_sys'));
32
33 if ((! $ARGV[0]) or ($ARGV[0] =~ /^-{1,2}h(elp)?$/i)) {
34 print "$/Find an atp file in the atp search path.$/$/";
35 print "usage : findatp <atpfile>$/$/the atp search path includes:$/";
36 map {print "\t$_$/"} (@search_path);
37 print $/;
38 exit;
39 };
40
41 my $atpfile = $ARGV[0];
42 ($atpfile =~ /\.$/) and $atpfile .= "atp";
43 ($atpfile =~ /\.atp$/) or $atpfile .= ".atp";
44
45
46 foreach (@search_path) {
47 opendir DIR, $_ or die $!;
48 my @list = grep { /^$atpfile$/ } readdir(DIR);
49 closedir DIR;
50 if (@list) {
51 print "$atpfile was found in $_$/";
52 exit;
53 };
54 };
55
56 print "$atpfile was not found in the atp search path:$/";
57 map {print "\t$_$/"} (@search_path);
58
59 1;
60
61 __END__
62
63 =head1 NAME
64
65 findatp - query the search path for a specific Atoms template file
66
67 =head1 SYNOPSIS
68
69 findatp <template_file_name>
70
71 =head1 DESCRIPTION
72
73 This little program tells you where in the search path a specific
74 Atoms template file is found. Running this program with no arguments
75 will return text showing the search path for template files.
76
77 =head1 AUTHOR
78
79 Bruce Ravel, [email protected]
80 http://cars9.uchicago.edu/~ravel
81
82 =cut