[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/misc/info .bdp/import.pl .bdp/nettoie_bdp.... [rel_2_2]
From: |
Henri-Damien LAURENT |
Subject: |
[Koha-cvs] koha/misc/info .bdp/import.pl .bdp/nettoie_bdp.... [rel_2_2] |
Date: |
Fri, 27 Jan 2006 15:29:13 +0000 |
CVSROOT: /cvsroot/koha
Module name: koha
Branch: rel_2_2
Changes by: Henri-Damien LAURENT <address@hidden> 06/01/27 15:29:13
Added files:
misc/info/.bdp : import.pl nettoie_bdp.pl
misc/info/etc : koha.conf koha-httpd.conf
misc/info/nautilus-scripts: importe.sh supprime.sh
misc/info : Installation Koha sous Windows.sxw
Log message:
Ajout : French town library Install Documentation and special files.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/.bdp/import.pl?only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/.bdp/nettoie_bdp.pl?only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/etc/koha.conf?only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/etc/koha-httpd.conf?only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/nautilus-scripts/importe.sh?only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/nautilus-scripts/supprime.sh?only_with_tag=rel_2_2&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/Installation.diff?only_with_tag=rel_2_2&tr1=&tr2=&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/Koha.diff?only_with_tag=rel_2_2&tr1=&tr2=&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/sous.diff?only_with_tag=rel_2_2&tr1=&tr2=&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/koha/koha/misc/info/Windows.sxw?only_with_tag=rel_2_2&rev=1.1.2.1
Patches:
Index: koha/misc/info/.bdp/import.pl
diff -u /dev/null koha/misc/info/.bdp/import.pl:1.1.2.1
--- /dev/null Fri Jan 27 15:29:13 2006
+++ koha/misc/info/.bdp/import.pl Fri Jan 27 15:29:12 2006
@@ -0,0 +1,230 @@
+#!/usr/bin/perl
+# small script that import an iso2709 file into koha 2.0
+
+use strict;
+
+use MARC::File::USMARC;
+use MARC::Record;
+use MARC::Batch;
+use C4::Context;
+use C4::Biblio;
+use C4::Date;
+use Time::HiRes qw(gettimeofday);
+
+use Getopt::Long;
+my ( $input_marc_file) = ('');
+my ($version, $test_parameter,$char_encoding, $annexe);
+GetOptions(
+ 'file:s' => \$input_marc_file,
+ 'h' => \$version,
+ 't' => \$test_parameter,
+ 'c:s' => \$char_encoding,
+ 'a:s' => \$annexe,
+);
+
+if ($version || ($input_marc_file eq '')) {
+ print <<EOF
+Script pour importer un fichier iso2709 dans Koha.
+Paramètres :
+\th : Cet écran d'aide
+\tfile /chemin/vers/fichier/fichier.iso2709 : Le fichier à importer
+\tt : test mode : Ne fait rien, sauf parser le fichier.
+\tc : L'encodate des caractères. UNIMARC (valeur par défaut) ou MARC21
+SAMPLE : ./import.pl -file /home/koha/bdp82-janvier.iso2709
+EOF
+;#'/
+die;
+}
+
+my $dbh = C4::Context->dbh;
+if ($test_parameter) {
+ print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
+}
+$|=1; # flushes output
+
+$char_encoding = 'UNIMARC' unless ($char_encoding);
+my $starttime = gettimeofday;
+my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
+$batch->warnings_off();
+$batch->strict_off();
+my $i=0;
+#1st of all, find item MARC tag.
+my ($tagfield,$tagsubfield) =
&MARCfind_marc_from_kohafield($dbh,"items.itemnumber");
+while ( my $record = $batch->next() ) {
+ $i++;
+ print ".";
+ my $timeneeded = gettimeofday - $starttime;
+ print "$i in $timeneeded s\n" unless ($i % 50);
+ #now, parse the record, extract the item fields, and store them in
somewhere else.
+
+ ## create an empty record object to populate
+ my $newRecord = MARC::Record->new();
+
+# noter le champ 908 (public visé). => ca ne doit rien donner dans les
fichiers BDP
+
+ # go through each field in the existing record
+ foreach my $oldField ( $record->fields() ) {
+ # just reproduce tags < 010 in our new record
+ if ( $oldField->tag() < 10 ) {
+ $newRecord->append_fields( $oldField );
+ next();
+ }
+
+ # store our new subfield data in this list
+ my @newSubfields = ();
+
+ # go through each subfield code/data pair
+ foreach my $pair ( $oldField->subfields() ) {
+ $pair->[1] =~ s/\<//g;
+ $pair->[1] =~ s/\>//g;
+ # supprimer les - dans l'ISBN
+ if ($oldField->tag() eq '010' && $pair->[0] eq 'a') {
+ $pair->[1] =~ s/-//g;
+ }
+ # supprimer les () dans le titre
+ if ($oldField->tag() eq '200' && $pair->[0] eq 'a') {
+# warn "==>".$pair->[1];
+ $pair->[1] =~ s/\x88//g;
+ $pair->[1] =~ s/\x89//g;
+ }
+ if ($oldField->tag() eq '995' && $pair->[0] eq 'f') {
+# warn "==>".$pair->[1];
+ $pair->[0] = 'j';
+ $pair->[1] = "a".$pair->[1]."b";
+ }
+ if ($oldField->tag() eq '995' && $pair->[0] eq 'c') {
+# warn "==>".$pair->[1];
+ $pair->[1] = "BIB";
+ }
+ if ($oldField->tag() eq '995' && $pair->[0] eq 'a') {
+# warn "==>".$pair->[1];
+ $pair->[1] = "Med";
+ $pair->[0] = 'b';
+ }
+ # on ignore le 995$o (notforloan dans Koha)
+ push( @newSubfields, $pair->[0],
char_decode($pair->[1],$char_encoding)) unless ($oldField->tag() eq 995 and
$pair->[0] eq 'o');
+ }
+
+ # Ajouter le nouveau champ dans le MARC::Record, en déplacant
le 906 en 610 (indexation libre)
+ my $newField;
+# if ($oldField->tag() eq 906) {
+# $newField = MARC::Field->new(
+# 610,
+# $oldField->indicator(1),
+# $oldField->indicator(2),
+# @newSubfields
+# );
+# } else {
+ $newField = MARC::Field->new(
+ $oldField->tag(),
+ $oldField->indicator(1),
+ $oldField->indicator(2),
+ @newSubfields
+ );
+# }
+ $newRecord->append_fields( $newField );
+ }
+ # ajouter itemtypes
+# print $record->as_formatted unless $record->field("995");
+ my $cote =$record->field("995")->subfield("k");
+ my $itemtypefield;
+ if ($newRecord->field('200')) {
+ my $type;
+ $type = "SF" if $cote=~/^SF /;
+ $type = "RP" if $cote=~/^RP /;
+ $type = "BDA" if ($cote=~/^BD / && $cote!~/\([J|R|B]\)/);
+ $type = "BD" if ($cote=~/^BD / && $cote=~/\([J|R|B]\)\s*$/);
+ $type = "JR" if ($cote=~/^R? / && $cote=~/\([J|R|B]\)\s*$/);
+ $type = "R" if ($cote=~/^R / && $cote!~/\([J|R|B]\)/);
+ $type = "RP" if ($cote=~/^RP / && $cote!~/\([J|R|B]\)/);
+ $type = "RV" if ($cote=~/^RV / && $cote!~/\([J|R|B]\)/);
+ $type = "RH" if ($cote=~/^RH / && $cote!~/\([J|R|B]\)/);
+ $type = "JD" if ($cote=~/^[0-9.]* / &&
$cote=~/\([J|R|B]\)\s*$/);
+ $type = "RP" if ($cote=~/^RP / && $cote!~/\([J|R|B]\)/);
+ $type = "ED" if ($cote=~/^C / && $cote=~/\([J|R|B]\)\s*$/);
+ $type = "RV" if ($cote=~/^[0-9.]* / && $cote!~/\([J|R|B]\)/);
+ $type = "A" if ($cote=~/^A /);
+ $type = "N" if ($cote=~/^N /);
+ $type = "BDP" unless ($type);
+ $newRecord->field('200')->add_subfields('b' => $type,
+ );
+ }
+ if ($newRecord->field('317')) {
+ my $date;
+ $date = format_date('today');
+ $newRecord->field('317')->add_subfields('a' => $date,
+ );
+ } else {
+ my $date;
+ $date = format_date('today');
+ my $newField = MARC::Field->new('317','','','a'=>$date);
+ $newRecord->append_fields($newField)
+ }
+ if ($newRecord->field('010') &&
$newRecord->field('010')->subfield('d')){
+ my $tmpField = $newRecord->field('010')->clone;
+ $newRecord->delete_field($tmpField);
+ if ($newRecord->field('995')){
+
$newRecord->field('995')->add_subfields('u'=>$tmpField->subfield('d'));
+ }else{
+ my $Field=
MARC::Field->new('995','','','u'=>$tmpField->subfield('d'));
+ $newRecord->insert_fields_ordered($Field);
+ }
+ }
+
+ my @fields = $newRecord->field($tagfield);
+ my @items;
+ my $nbitems=0;
+
+ foreach my $field (@fields) {
+ my $item = MARC::Record->new();
+ if ($field->subfield('b')){$field->update('b' => 'Med');} else
{$field->add_subfields('b' => 'Med');}
+ if ($field->subfield('c')){$field->update('c' => 'BIB');} else
{$field->add_subfields('c' => 'BIB');}
+ $field->add_subfields('s' => 'Médiathèque');
+# if ($public_vise eq "A partir de 1 an") {
+# $field->update('q' => '0-5');
+# } elsif ($public_vise eq "A partir de 2 ans") {
+# $field->update('q' => '0-5');
+# } elsif ($public_vise eq "A partir de 3 ans") {
+# $field->update('q' => '0-5');
+# } elsif ($public_vise eq "A partir de 4 ans") {
+# $field->update('q' => '0-5');
+# } elsif ($public_vise eq "A partir de 6 ans") {
+# $field->update('q' => '06-09');
+# } elsif ($public_vise eq "A partir de 7 ans") {
+# $field->update('q' => '06-09');
+# } elsif ($public_vise eq "A partir de 8 ans") {
+# $field->update('q' => '06-09');
+# } elsif ($public_vise eq "A partir de 9 ans") {
+# $field->update('q' => '06-09');
+# } elsif ($public_vise eq "A partir de 10 ans") {
+# $field->update('q' => '10-11');
+# } elsif ($public_vise eq "A partir de 11 ans") {
+# $field->update('q' => '10-11');
+# } elsif ($public_vise eq "A partir de 12 ans") {
+# $field->update('q' => '12-16');
+# } elsif ($public_vise eq "A partir de 13 ans") {
+# $field->update('q' => '12-16');
+# } elsif ($public_vise eq "A partir de 14 ans") {
+# $field->update('q' => '12-16');
+# } else {
+# $field->update('q' => '18');
+# }
+ $item->append_fields($field);
+ push @items,$item;
+ $newRecord->delete_field($field);
+ $nbitems++;
+ }
+ # now, create biblio and items with NEWnewXX call.
+ unless ($test_parameter) {
+ warn "biblio : ".$newRecord->as_formatted;
+ my ($bibid,$oldbibnum,$oldbibitemnum) =
NEWnewbiblio($dbh,$newRecord,'') if $nbitems>0;
+ for (my $i=0;$i<$nbitems;$i++) {
+ my $itemfield = $items[$i];
+ warn "Exemplaire $i : ".$itemfield->as_formatted;
+ NEWnewitem($dbh,$itemfield,$bibid,'');
+ }
+ }
+}
+# $dbh->do("unlock tables");
+my $timeneeded = gettimeofday - $starttime;
+print "$i MARC record done in $timeneeded seconds\n";
Index: koha/misc/info/.bdp/nettoie_bdp.pl
diff -u /dev/null koha/misc/info/.bdp/nettoie_bdp.pl:1.1.2.1
--- /dev/null Fri Jan 27 15:29:13 2006
+++ koha/misc/info/.bdp/nettoie_bdp.pl Fri Jan 27 15:29:12 2006
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+# small script that deletes biblios which barcodes are in the parameter file.
+
+use strict;
+
+use MARC::File::USMARC;
+use MARC::Record;
+use MARC::Batch;
+use C4::Context;
+use C4::Biblio;
+use Time::HiRes qw(gettimeofday);
+
+use Getopt::Long;
+my ( $input_file) = ('');
+my ($version, $test_parameter,$char_encoding, $annexe);
+GetOptions(
+ 'file:s' => \$input_file,
+ 'h' => \$version,
+ 't' => \$test_parameter,
+);
+
+if ($version || ($input_file eq '')) {
+ print <<EOF
+Script pour supprimer des notices en série dans Koha
+Paramètres :
+\th : Cet écran d'aide
+\tfile /chemin/vers/fichier/fichier.codebarres : Le fichier contenant les
code-barres à supprimer. Chaque code-barre est sur une ligne différente.
+\tt : test mode : Ne fait rien, sauf parser le fichier.
+SAMPLE : ./nettoie_bdp.pl -file /home/koha/liste_barcodes.txt
+EOF
+;#'
+die;
+}
+
+my $dbh = C4::Context->dbh;
+if ($test_parameter) {
+ print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
+}
+$|=1; # flushes output
+
+my $starttime = gettimeofday;
+open FILE, $input_file || die "erreur : fichier introuvable";
+
+my $i=0;
+#1st of all, find barcode MARC tag.
+my ($tagfield,$tagsubfield) =
&MARCfind_marc_from_kohafield($dbh,"items.barcode");
+my $sth = $dbh->prepare("select bibid from marc_subfield_table where
tag=$tagfield and subfieldcode='$tagsubfield' and subfieldvalue=?");
+
+while ( my $barcode = <FILE> ) {
+ $barcode=~tr#\n\r\l# #;
+ $barcode=~s/\s//g;
+ chomp $barcode;
+ $barcode="a".$barcode."b" if not ($barcode=~/a|b/);
+ $i++;
+ $sth->execute($barcode);
+ my ($bibid) = $sth->fetchrow;
+ if ($test_parameter) {
+ if ($bibid) {
+ print "suppression de $bibid (code barre $barcode)\n";
+ } else {
+ print "Problème avec le code barre $barcode :
introuvable dans la base\n";
+ }
+ } else {
+ if ($bibid) {
+ &NEWdelbiblio($dbh,$bibid);
+ } else {
+ print "Problème avec le code barre $barcode :
introuvable dans la base\n";
+ }
+ print ".";
+ my $timeneeded = gettimeofday - $starttime;
+ print "$i in $timeneeded s\n" unless ($i % 50);
+
+ }
+# print "B : $barcode";
+}
+# $dbh->do("unlock tables");
+my $timeneeded = gettimeofday - $starttime;
+print "$i MARC record done in $timeneeded seconds\n";
Index: koha/misc/info/etc/koha-httpd.conf
diff -u /dev/null koha/misc/info/etc/koha-httpd.conf:1.1.2.1
--- /dev/null Fri Jan 27 15:29:13 2006
+++ koha/misc/info/etc/koha-httpd.conf Fri Jan 27 15:29:12 2006
@@ -0,0 +1,23 @@
+
+NameVirtualHost *
+
+
+<VirtualHost *>
+ ServerAdmin address@hidden
+ DocumentRoot /koha-2.2.5/opac-html
+ ScriptAlias /cgi-bin/koha/ /koha-2.2.5/opac-cgi/
+ ServerName opac
+ ErrorLog logs/opac-error_log
+ CustomLog logs/opac-access_log common
+ SetEnv PERL5LIB "c:/koha-2.2.5/modules"
+</VirtualHost>
+
+<VirtualHost *>
+ ServerAdmin address@hidden
+ DocumentRoot /koha-2.2.5/intranet-html
+ ScriptAlias /cgi-bin/koha/ /koha-2.2.5/intranet-cgi/
+ ServerName intranet
+ ErrorLog logs/intranet-error_log
+ CustomLog logs/intranet-access_log common
+ SetEnv PERL5LIB "c:/koha-2.2.5/modules"
+</VirtualHost>
Index: koha/misc/info/etc/koha.conf
diff -u /dev/null koha/misc/info/etc/koha.conf:1.1.2.1
--- /dev/null Fri Jan 27 15:29:13 2006
+++ koha/misc/info/etc/koha.conf Fri Jan 27 15:29:12 2006
@@ -0,0 +1,9 @@
+database=koha
+hostname=localhost
+user=kohaadmin
address@hidden
+intranetdir=c:/koha-2.2.5/intranet-cgi
+opacdir=c:/koha-2.2.5/opac-cgi
+kohaversion=2.2.2
+opachtdocs=c:/koha-2.2.5/opac-html/opac-tmpl
+intrahtdocs=c:/koha-2.2.5/intranet-html/intranet-tmpl
Index: koha/misc/info/nautilus-scripts/importe.sh
diff -u /dev/null koha/misc/info/nautilus-scripts/importe.sh:1.1.2.1
--- /dev/null Fri Jan 27 15:29:13 2006
+++ koha/misc/info/nautilus-scripts/importe.sh Fri Jan 27 15:29:12 2006
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# This script opens a gnome-terminal in the directory you select.
+#
+# Distributed under the terms of GNU GPL version 2 or later
+#
+# Copyright (C) Keith Conger <address@hidden>
+#
+# Install in your ~/Nautilus/scripts directory.
+# You need to be running Nautilus 1.0.3+ to use scripts.
+
+export KOHA_CONF="/etc/koha/koha.conf"
+export PERL5LIB='/usr/local/koha/intranet/modules'
+/home/responsables/valerie/.bdp/import.pl -file "$1"
+
+
Index: koha/misc/info/nautilus-scripts/supprime.sh
diff -u /dev/null koha/misc/info/nautilus-scripts/supprime.sh:1.1.2.1
--- /dev/null Fri Jan 27 15:29:13 2006
+++ koha/misc/info/nautilus-scripts/supprime.sh Fri Jan 27 15:29:12 2006
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# This script opens a gnome-terminal in the directory you select.
+#
+# Distributed under the terms of GNU GPL version 2 or later
+#
+# Copyright (C) Keith Conger <address@hidden>
+#
+# Install in your ~/Nautilus/scripts directory.
+# You need to be running Nautilus 1.0.3+ to use scripts.
+
+export KOHA_CONF="/etc/koha/koha.conf"
+export PERL5LIB='/usr/local/koha/intranet/modules'
+/home/responsables/valerie/.bdp/nettoie_bdp.pl -file "$1"
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha/misc/info .bdp/import.pl .bdp/nettoie_bdp.... [rel_2_2],
Henri-Damien LAURENT <=