From d0535b2b929765ab454e987850459e6ee897eab2 Mon Sep 17 00:00:00 2001 From: jaron Date: Fri, 24 Aug 2007 13:17:01 +0000 Subject: [PATCH] pick your script added functionality to prompt user for which script they want to run on the particular record under consideration. git-svn-id: svn+ssh://rubyforge.org/var/svn/zcc/trunk@307 695555e7-a3f4-42c9-822d-1d0ed3746087 --- bin/zcc | 37 ++++++++++++++++++++++++++++++--- examples/zcc.yaml | 61 ++++++++++++++++++++++++++++++++++-------------------- website/index.html | 8 +++++-- website/koha.html | 47 ++++++++++++++++++++++++++--------------- website/zcc.html | 50 ++++++++++++++++++++++++++++++++------------ website/zebra.html | 11 ++++++++-- 6 files changed, 155 insertions(+), 59 deletions(-) diff --git a/bin/zcc b/bin/zcc index d9aace8..a13f407 100644 --- a/bin/zcc +++ b/bin/zcc @@ -21,13 +21,17 @@ require 'unicode' require 'zcc' include ZCC - -opts = GetoptLong.new( [ '--yaml', '-y', GetoptLong::REQUIRED_ARGUMENT ] ) +$testing = false +opts = GetoptLong.new( [ '--yaml', '-y', GetoptLong::REQUIRED_ARGUMENT ], + ['--testing', '-t', GetoptLong::NO_ARGUMENT] + ) opts_yaml ='' opts.each do |opt, arg| case opt when '--yaml' opts_yaml = arg + when '--testing' + $testing = true end end @@ -65,6 +69,8 @@ zservers.compact! labels = yamlfile['labels'] scripting = yamlfile['scripting'] +#puts scripting.inspect +#gets $procs = yamlfile['procs'] TO_SHOW = yamlfile['to_show'] @@ -150,12 +156,37 @@ loop { taken.records.each do |final_taken| #puts final_taken.class; STDIN.gets #SCRIPTING and EDITING + def which_script scripting + loop do + choose do |scripting_menu| + scripting_menu.layout = :list + scripting_menu.index = :number + scripting_menu.readline = true + scripting_menu.shell = true + scripting_menu.prompt = "Enter which script you would like to run on this record: " + scripting_menu.select_by = :index_or_name + scripting.each do |key, value| + scripting_menu.choice(key, "no help, ha!") do |cmd, d| + if cmd == :help + next + else + return scripting[cmd] + end + end + end + end + end + end + if SCRIPTING print $clear_code print "\a" + picked_scripting = which_script scripting + print $clear_code + print "\a" say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}") say("SCRIPTING...".bold.white.on_black) - final_taken.local_script(scripting) + final_taken.local_script(picked_scripting) end if EDITING diff --git a/examples/zcc.yaml b/examples/zcc.yaml index 51914ba..39521ce 100644 --- a/examples/zcc.yaml +++ b/examples/zcc.yaml @@ -108,28 +108,45 @@ labels: # turned on in the main script with the value of the # constant SCRIPTING at the head of the file. ################################################# -scripting: -- [remove, 9XX] -- [create-field, 942, " ", " "] #create new field with empty indicators -- [create-field, 952, " ", " "] -- [append-subfield, 952, 2, DLC] -- [append-subfield, 952, b, MRML] -#- [append-subfield, 952, c, BIO] # BIO, Fic -- [append-subfield, 942, c, BOOK] -- [append-subfield, 942, k, proc get_dewey] # "proc name" is the way to get - # the script to evaluate a block - # of code. See below. comment out for BIO -- [append-subfield, 942, j, proc get_decimal] #comment out for BIO -#- [append-subfield, 942, l, proc prompt_cutter] #BIO -- [append-subfield, 942, l, proc get_cutter] #comment out for BIO -- [append-subfield, 952, k, proc get_combined_callnum] -- [prompt, 942, x, IS THERE A CIP] -- [append-subfield, 942, y, proc get_cip_callnum] -- [prompt, 942, z, OLD CALL NUMBER] -- [prompt, 952, z, PUBLIC NOTE FOR ITEM] -- [prompt, 952, x, INTERNAL NOTE] -- [proc barcode_and_itemnum] -# [sort-tags] #This currently doesn't work. +scripting: + non_fiction: + - [remove, 9XX] + - [create-field, 942, " ", " "] #create new field with empty indicators + - [create-field, 952, " ", " "] + - [append-subfield, 952, 2, DLC] + - [append-subfield, 952, b, MRML] + - [append-subfield, 942, c, BOOK] + - [append-subfield, 942, k, proc get_dewey] # "proc name" is the way to get + # the script to evaluate a block + # of code. See below. comment out for BIO + - [append-subfield, 942, j, proc get_decimal] #comment out for BIO + - [append-subfield, 942, l, proc get_cutter] #comment out for BIO + - [append-subfield, 952, k, proc get_combined_callnum] + - [prompt, 942, x, IS THERE A CIP] + - [append-subfield, 942, y, proc get_cip_callnum] + - [prompt, 942, z, OLD CALL NUMBER] + - [prompt, 952, z, PUBLIC NOTE FOR ITEM] + - [prompt, 952, x, INTERNAL NOTE] + - [proc barcode_and_itemnum] + # [sort-tags] #This currently doesn't work. + + biography: + - [remove, 9XX] + - [create-field, 942, " ", " "] #create new field with empty indicators + - [create-field, 952, " ", " "] + - [append-subfield, 952, 2, DLC] + - [append-subfield, 952, b, MRML] + - [append-subfield, 952, c, BIO] # BIO, Fic + - [append-subfield, 942, c, BOOK] + - [append-subfield, 942, l, proc prompt_cutter] #BIO + - [append-subfield, 952, k, proc get_combined_callnum] + - [prompt, 942, x, IS THERE A CIP] + - [append-subfield, 942, y, proc get_cip_callnum] + - [prompt, 942, z, OLD CALL NUMBER] + - [prompt, 952, z, PUBLIC NOTE FOR ITEM] + - [prompt, 952, x, INTERNAL NOTE] + - [proc barcode_and_itemnum] + #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/website/index.html b/website/index.html index 607342b..7793e71 100644 --- a/website/index.html +++ b/website/index.html @@ -33,19 +33,23 @@

zcc projects

Get Version

- 0.1.2 + 0.2.0

→ ‘zcc’

+

What

+

Zcc projects is a collection of tools written in Ruby to help with copy cataloging.

-

THIS IS alpha SOFTWARE. IT MIGHT MANGLE YOUR MARC AND CORRUPT YOUR CATALOG.

+

THIS IS alpha SOFTWARE. IT MIGHT MANGLE YOUR MARC AND CORRUPT YOUR CATALOG.

+

zcc project releases so far

+

zcc zcc is the main copy cataloging script.

diff --git a/website/koha.html b/website/koha.html index bd758f6..317d3e3 100644 --- a/website/koha.html +++ b/website/koha.html @@ -33,53 +33,66 @@

Using Koha with zcc

Get Version

- 0.1.2 + 0.2.0

Koha + zcc

Hints

-
    + +
    1. Follow all the directions on the main zcc page carefully. Please let me know if you run into problems with configuration.
    2. -
    +
+ -
    +
    1. zcc is not a part of Koha and is not developed by the same folks.
    2. -
    +
+ -
    +
    1. zcc only creates utf-8 encoded records. If you want MARC-8 encoded records you’re on your own. MARC-8 encoding has already caused enough problems in this world, so I encourage folks to move to UTF-8 ASAP. If you use a different encoding that you want supported, please let me know. To set up Koha properly for dealing with UTF-8 encoded records see this wiki page
    2. -
    +
-
    + +
    1. ZCC currently only works with a default install as paths are hardcoded. If there’s a need I’ll make it configurable for someone. Make sure the Koha modules are a part of your path. I accomplish this by adding “export PERL5LIB=/usr/local/koha/intranet/modules” and “export KOHA_CONF=/etc/koha.conf” without the quotes to my .bashrc (or add the path to /etc/profile for the root user). If your paths differ from the preceding saving to Koha will not work.
    2. -
    +
+ + +
    +
  1. You can then have 3 choices on how to get the records into koha: -
      -
    1. You can then have 3 choices on how to get the records into koha:
        +
        • Using the Koha Administration interface you can “Upload MARC records to the resevoir.” Then complete processing on the records like adding items and barcodes within the Koha web interface. The resevoir may strip out some fields that usually hold local content.
        • -
        +
      -
        + +
        • If you have processed your records fully to include item numbers and barcodes, you can use the bulkmarcimport script to put the records directly into your database. I’ve used bulkmarcimport without modification without problem. You may have different results and I’d like to hear them.
        • -
        +
      +
      perl
         /usr/local/koha/intranet/scripts/misc/migration_tools/bulkmarcimport.pl -v -file
         /path/to/marc-file.mrc
      +

      That is all one line.

      -
        +
        • Or configure the save_record_syntax of your zcc.yaml file to ‘koha2’. If this gives you errors make sure you have exported environment variables with: “export -p”. You may also need to change the permissions on /etc/koha.conf to allow all users to view the file. If you get errors you can (though it might not be the best solution) do the following as root:
        • -
        +
      +
      chmod 644 /etc/koha.conf
    2. -
    +
+

Contact

+

I use ZCC and Koha for my own work. So I’m very interested in making ZCC work better with Koha. Please send your comments, suggestions and patches to Jason Ronallo

diff --git a/website/zcc.html b/website/zcc.html index a3d58b8..882e1a8 100644 --- a/website/zcc.html +++ b/website/zcc.html @@ -33,28 +33,34 @@

zcc

Get Version

- 0.1.2 + 0.2.0

→ ‘zcc’

+

What

+

Z Copy Cataloging is a command line tool written in Ruby to make your MARC record copy cataloging faster and more accurate. The ‘Z’ may stand for Zippy if you really want it to.

-

THIS IS alpha SOFTWARE. IT MIGHT MANGLE YOUR MARC AND CORRUPT YOUR CATALOG.

+

THIS IS alpha SOFTWARE. IT MIGHT MANGLE YOUR MARC AND CORRUPT YOUR CATALOG.

+

Requirements

+

Ruby 1.8

-

YAZ I suggest adding the indexdata repositories for your distro (Debian or Redhat) and installing that way. From a footnote to ruby-zoom: If you build from source, make sure you pass the—enable-shared option to the configure script before building YAZ, by default it does not build shared libraries required by Ruby/ZOOM.

+

YAZ I suggest adding the indexdata repositories for your distro (Debian or Redhat) and installing that way. From a footnote to ruby-zoom: If you build from source, make sure you pass the—enable-shared option to the configure script before building YAZ, by default it does not build shared libraries required by Ruby/ZOOM.

Gems

+
sudo gem install zcc marc zoom unicode highline term-ansicolor
+

ruby-marc

@@ -66,6 +72,7 @@

Repository

+

A new gem is super easy to release to rubyforge, so expect that the gem on rubyforge is up-to-date for working features, though not necessarily for small changes. If you want to build the gem yourself, it will also be super easy once you set things up.

@@ -73,10 +80,12 @@
$ sudo gem install newgem --include-dependencies
+

Grab the latest from the svn repository:

-
$ svn co svn://208.78.97.122/zcc
+
$ svn checkout svn://rubyforge.org/var/svn/zcc/trunk
+

To build and install the gem as a user most easily, the user must be added to the sudoers list. On my system I do this by running visudo as root. For more information on sudoers and possible settings that may be more secure consult: Sudoers Manual

@@ -85,18 +94,22 @@
Cmnd_Alias GEM=/usr/bin/gem
 user     ALL=GEM
+

Now as a user you can build and install the gem on your own system:

$ cd zcc
 $ rake local_deploy
+

For more tasks take a look at the output of:

$ rake -T 
+

Features

-

Z39.50 search for records. Configure ZCC for as many targets as you like grouped in order of preference. A relatively current list of targets is provided based on the targettest list (examples/zservers.yaml). If you find the perfect record with the first target other targets do not have to be searched.

+ +

Z39.50 search for records. Configure ZCC for as many targets as you like grouped in order of preference. A relatively current list of targets is provided based on the targettest list (examples/zservers.yaml). If you find the perfect record with the first target other targets do not have to be searched.

Search by Title, ISBN or LCCN Currently three searches are supported. From the same prompt you may search either by Title, ISBN or LCCN (with dash).

@@ -134,6 +147,7 @@ $ rake local_deploy

Configuration

+

Because of all the scripting and csv features zcc requires a lot of configuration. Currently the configuration files are my own. I use them and they work for my purposes, but they will not work for yours. Once you have configured zcc, though, you should be copy cataloging much faster.

@@ -142,27 +156,31 @@ $ rake local_deploy
cd ~/.zcc
 cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/* .
+

Now if you want your retrieved records to be indexed and searchable over Z39.50 via zebra check out this quick start page: Very simple setup of local zebra server

Use

+

$ zcc

-
    +
    1. Configure both ~/.zcc/zcc.yaml.
    2. -
    3. From the command line run zcc
    4. -
    5. Next to each shown result is a number. Numbering starts with zero.
    6. -
    7. ZCC command line: type ‘help’ to see the possible help options.
    8. -
    +
  1. From the command line run zcc
  2. +
  3. Next to each shown result is a number. Numbering starts with zero.
  4. +
  5. ZCC command line: type ‘help’ to see the possible help options.
  6. +
+ + +

TODO

-

TODO

Smart character set conversion Currently incoming records are assumed to be marc8 and are converted to utf8. This is complex. Let me know what you need here. v. 0.0.3+ checks leader byte 9 for character encoding and either keeps it as UTF8 or convert from MARC8 to UTF8. Uses ruby-zoom’s xml method for conversion.

-

TUI If there is interest in this script, I’m hoping to make a nice Text User Interface with curses or ncurses. Currently everything just scrolls up the terminal. Since v. 0.0.3 there are some nicer TUI elements like highlighting With version 0.1.0, there’s a much nicer configurable TUI.

+

TUI If there is interest in this script, I’m hoping to make a nice Text User Interface with curses or ncurses. Currently everything just scrolls up the terminal. Since v. 0.0.3 there are some nicer TUI elements like highlighting With version 0.1.0, there’s a much nicer configurable TUI.

Automatic retrieval of authority records. I already have a separate script in the works that can retrieve authority records for names (not subjects). I’d like to work that as an option into the main script.

@@ -188,16 +206,19 @@ cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/* .

Suggestions

+

Perl and MARC::Lint To have error checking of records turned on you must also have Perl and MARC::Lint installed.

Using Koha with zcc

-

There is no integration yet between Koha and zcc, but I use both so am working towards that end. For now you can find some help on this page: using Koha with zcc

+ +

ZCC can now use Koha2’s bulkmarcimport script to insert records directly into the Koha database. For more information see this page: using Koha with zcc

Help/paches

+

email: Jason Ronallo

@@ -206,11 +227,13 @@ cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/* .

Will work for Ruby books

+

If you’d like to sponsor the addition of a feature to ZCC or need a change to better meet your workflow, I will work for Ruby books. Up to now I’ve, requested Programming Ruby, Ruby Cookbook, Agile Web Development with Rails and others from libraries via Inter-Library Loan. I never get to keep them as long as I’d like. I’d like to have my own copies of these invaluable resources.

License

+

Copyright© 2007 Jason Ronallo

@@ -225,6 +248,7 @@ cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/* .

Contact

+

Comments are welcome. Send an email to Jason Ronallo.

diff --git a/website/zebra.html b/website/zebra.html index 34f08ca..3f0b74a 100644 --- a/website/zebra.html +++ b/website/zebra.html @@ -33,7 +33,7 @@

Very simple setup of local zebra server

Get Version

- 0.1.2 + 0.2.0

These instructions are probably incomplete for this release. Please let me know if you find errors.

@@ -49,22 +49,26 @@ You may have already moved the zebra directory into your .zcc directory. If not $ cd ~/.zcc $ cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/zebra . + Now change into the zebra directory:
 $ zebrasrv -D
 
+

You may see loaded filter module messages and then be returned to a prompt. Now you can try it out:

@@ -95,18 +99,21 @@ Records: 1 650 0 $a Bicycle touring $x Equipment and supplies. 991 $b c-GenColl $h GV1044 $i .B88 1994 $t Copy 1 $w BOOKS +

If you see a record displayed then it works! Congratulations.

Now you can configure your local zserver in the zcc.yaml file in ~/.zcc. Add (or uncomment) this line if necessary:
- [localhost,    9999,     zcc, 0]
My suggestion is to put this server in group 0 (zero) of your zservers to check in see whether you already have an appropriate record. +

When you want to add records to the zebra database manually you will need to return to your ~/.zcc/zebra directory and reindex the whole bunk of records. Just drop a UTF-8 encoded MARC21 record (IS02709) anywhere in the directory below ~/.zcc/zebra/records and it will be indexed after running this:

$ cd ~/.zcc/zebra
 $ zebraidx update records
-

To make this the default place to save records choose ‘zebra’ under save_record_syntax in zcc.yaml. This reindexing could take some time, especially if you have a large number of files, though zebra does index quickly. Right now the database is reindexed after each insertion of a record. Not optimal and I’m looking at other ways to do this (only reindex on quit?) We would like to add extended services for record insert and update to ruby-zoom Currently the C-binding is incomplete. Please let me know if you’re a developer willing to do the work (jronallo+zoom@gmail.com).

+ +

To make this the default place to save records choose ‘zebra’ under save_record_syntax in zcc.yaml. This reindexing could take some time, especially if you have a large number of files, though zebra does index quickly. Right now the database is reindexed after each insertion of a record. Not optimal and I’m looking at other ways to do this (only reindex on quit?) We would like to add extended services for record insert and update to ruby-zoom Currently the C-binding is incomplete. Please let me know if you’re a developer willing to do the work (jronallo+zoom@gmail.com).

If you shutdown your computer make sure to restart the zebrasrv!

-- 2.11.4.GIT