[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gNewSense-users] Proposal regarding KFV data batch handling
From: |
Bake Timmons |
Subject: |
Re: [gNewSense-users] Proposal regarding KFV data batch handling |
Date: |
Thu, 10 Jul 2008 09:19:25 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
> OK, I will install PmWiki, etc., play with some code, and post
> whatever I think might be useful. Thanks.
>
> This is a one-off thing, so there's no need to be fancy. Can the stats
> aggregation code collect a list of non-free files while it's doing the maths?
The attached perl script prints pathnames of non-free file entries
(i.e., entries that are 0% free) in KFV tables. The following text
comes from a larger comment that started an earlier version of the
script:
Usage: filter-non-free-files [file of sorted path names]
Given gNewSense KFV table source on standard input, print on
standard output relative file paths corresponding to any table rows
specifying non-free files. Such table rows are converted to regular
expressions(*) that are matched against a special file of sorted,
relative file paths. A single optional argument can indicate the
location of the special file, otherwise the default value is
"all-file-paths".
Here is an example of creating the special file:
$ find linux-ubuntu-modules-2.6.24_16.23/ | sort > ~/kernel-files
Here is an extended example of use:
$ find /var/www/wiki.d/ -mtime -1 -type f -exec cat '{}' ';' \
| filter-non-free-files ~/kernel-files > to-remove-new
$ rm -fr $(cat to-remove-new)
$ touch removed \
&& cp removed removed-old \
&& sort --unique --merge removed-old to-remove-new > removed
The "removed" file in this case is a record of removed files and
could be included in a web page, for example.
(*) The reason for this conversion to regexps is because of the
ambiguity of the file path representation in the KFV wiki table
entries: "-" could stand for "_" or ".".
#!/usr/bin/perl -w
# -*- Mode: Perl -*-
#
# Usage: filter-non-free-files [file of sorted path names]
#
# Given gNewSense KFV table source on standard input, print on
# standard output relative file paths corresponding to any table rows
# specifying non-free files. Such table rows are converted to regular
# expressions that are matched against a special file of sorted,
# relative file paths. A single optional argument can indicate the
# location of the special file, otherwise the default value is
# "all-file-paths".
# Here is an example of creating the special file:
#
# $ find linux-ubuntu-modules-2.6.24_16.23/ | sort > ~/kernel-files
#
# Here is an extended example of use:
#
# $ find /var/www/wiki.d/ -mtime -1 -type f -exec cat '{}' ';' \
# | filter-non-free-files ~/kernel-files > to-remove-new
# $ rm -fr $(cat to-remove-new)
# $ touch removed \
# && cp removed removed-old \
# && sort --unique --merge removed-old to-remove-new > removed
#
# The "removed" file in this case is a record of removed files and
# could be included in a web page, for example.
use strict;
use warnings;
use Carp;
use Readonly;
Readonly::Scalar my $FILE_PATHS => 'all-file-paths';
Readonly::Scalar my $PREFIX => 'Ubuntu-hardy-';
sub filter_non_free_paths {
my $arg = shift;
my @non_free_patterns;
my $line = qw{};
while ($line = <STDIN>) {
if ($line =~ /\|\|0%\|\|(N|Y)[^\/]/o and
$line =~ /$PREFIX([^|]+)/o) {
my $pattern = $1;
$pattern =~ s/--/\//g;
$pattern =~ tr/-/./;
push @non_free_patterns, qr/$pattern/;
}
}
@non_free_patterns = sort @non_free_patterns;
open my $FILE, '<', $arg or croak ("Could not open $arg");
while (my $pattern = shift @non_free_patterns) {
while (defined($line = <$FILE>) and $line !~ /$pattern/) {};
if ($line) {
print $line;
}
}
return close $FILE;
}
filter_non_free_paths $ARGV[0] || $FILE_PATHS;
exit 0;
- [gNewSense-users] Proposal regarding KFV data batch handling, Bake Timmons, 2008/07/08
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Karl Goetz, 2008/07/08
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Bake Timmons, 2008/07/08
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Brian Brazil, 2008/07/09
- Re: [gNewSense-users] Proposal regarding KFV data batch handling,
Bake Timmons <=
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Brian Brazil, 2008/07/12
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Bake Timmons, 2008/07/12
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Karl Goetz, 2008/07/12
- [gNewSense-users] Corrected URL (Re: Proposal regarding KFV data batch handling), Bake Timmons, 2008/07/12
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Brian Brazil, 2008/07/12
- [gNewSense-users] Corrected script Re: Proposal regarding KFV data batch handling, Bake Timmons, 2008/07/12
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Brian Brazil, 2008/07/13
- Re: [gNewSense-users] Proposal regarding KFV data batch handling, Karl Goetz, 2008/07/13
- [gNewSense-users] table, crap0101, 2008/07/16
- Re: [gNewSense-users] table, crap0101, 2008/07/16