~ubuntu-branches/ubuntu/oneiric/muse-el/oneiric

« back to all changes in this revision

Viewing changes to contrib/blosxom/getstamps.pl

  • Committer: Bazaar Package Importer
  • Author(s): Michael W. Olson (GNU address)
  • Date: 2008-01-09 15:51:46 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080109155146-0wwzermvvzs9rqzo
Tags: 3.11-3ubuntu1
* Merge with with Debian unstable (LP: #137284). Remaining Ubuntu changes:
  - Keep manual.
  - Set Ubuntu MOTU to be Maintainer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w --
 
2
 
 
3
#
 
4
# $Id: getstamps.pl,v 1.3 2007-08-19 13:46:54 welle Exp $
 
5
#
 
6
 
 
7
# Author: Michael Welle
 
8
 
 
9
# This file is available under the terms of the GNU General Public
 
10
# License, Version 2.
 
11
 
 
12
# Modified by Michael Olson to add Author note. license text, and to
 
13
# fix a use of "muse" rather than $muse_file_extension.
 
14
 
 
15
#my $tsfile = "/tmp/blog/timestamps";
 
16
my $tsfile = "-";
 
17
my $muse_file_extension = "muse";
 
18
 
 
19
#
 
20
#
 
21
#
 
22
sub process_file {
 
23
  my ($file) = @_;
 
24
 
 
25
 
 
26
  open( F, "<$file" );
 
27
 
 
28
  while ( <F> ) {
 
29
 
 
30
    if ( /^#date\s+(.+)$/ ) {
 
31
 
 
32
      close ( F );
 
33
      my $d = $1;
 
34
 
 
35
      $file =~ s/\.${muse_file_extension}$/\.txt/;
 
36
      $file =~ s/^\.\///;
 
37
 
 
38
      if ( $d =~ /(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)/ ) {
 
39
 
 
40
        printf TS "${file}=>$2/$3/$1 $4:$5\n";
 
41
        return;
 
42
 
 
43
      } # if
 
44
 
 
45
    } # if
 
46
 
 
47
  } # while
 
48
 
 
49
  close( F );
 
50
 
 
51
} # process_file
 
52
 
 
53
 
 
54
 
 
55
#
 
56
#
 
57
#
 
58
sub traverse_directory {
 
59
  my ($directory) = @_;
 
60
  local *DIR;
 
61
  my @files = ();
 
62
  my $pfad = "";
 
63
 
 
64
 
 
65
  opendir( DIR, $directory );
 
66
  @files = readdir( DIR );
 
67
  closedir( DIR );
 
68
 
 
69
 
 
70
  foreach my $file ( @files ) {
 
71
 
 
72
    next if ( !( $file =~ /^.*\.${muse_file_extension}$/ )
 
73
              || ($file eq '.') || ($file eq '..'));
 
74
 
 
75
 
 
76
    $path = "$directory/$file";
 
77
 
 
78
    if( -d $path ) {
 
79
 
 
80
       traverse_directory( $path );
 
81
 
 
82
    } else {
 
83
 
 
84
      process_file( $path );
 
85
 
 
86
    } #if
 
87
 
 
88
  } #foreach
 
89
 
 
90
} # traverse_directory
 
91
 
 
92
 
 
93
#
 
94
# Here we go...
 
95
#
 
96
 
 
97
open( TS, ">${tsfile}" );
 
98
 
 
99
if ( @ARGV == 0 ) {
 
100
 
 
101
  traverse_directory( "." );
 
102
 
 
103
} else {
 
104
 
 
105
  traverse_directory( $ARGV[0] );
 
106
 
 
107
} #if
 
108
 
 
109
close( TS );
 
110
 
 
111
exit 0;