mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Various fixes for windows: Remove dependency checking for windows builds as it would be a miracle if automatic installation succeeded. Provide a default termwidth for the CLI on windows.
Initial import of Perl script to edit PDF metadata
This commit is contained in:
parent
eb07f9c91f
commit
3f4f7e7b0b
13
setup.py
13
setup.py
@ -25,8 +25,12 @@ try:
|
||||
try:
|
||||
import Image
|
||||
except ImportError:
|
||||
if sys.platform not in ['win32', 'darwin']:
|
||||
print "Trying to install the Python Imaging Library"
|
||||
easy_install(["-f", "http://www.pythonware.com/products/pil/", "Imaging"])
|
||||
else:
|
||||
raise Exception('Please install the Python Imaging library manually from '\
|
||||
'http://www.pythonware.com/products/pil/')
|
||||
except Exception, e:
|
||||
print >> sys.stderr, e
|
||||
print >> sys.stderr, \
|
||||
@ -44,6 +48,10 @@ if sys.hexversion < 0x2050000:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
install_requires=[]
|
||||
if sys.platform not in ['win32', 'darwin']:
|
||||
install_requires = ["pyusb>=0.3.5", "pyxml>=0.8.4"]
|
||||
|
||||
setup(
|
||||
name='libprs500',
|
||||
packages = find_packages('src'),
|
||||
@ -54,7 +62,8 @@ setup(
|
||||
url = 'http://libprs500.kovidgoyal.net',
|
||||
package_data = { \
|
||||
'libprs500.gui' : ['*.ui'], \
|
||||
'libprs500.lrf' : ['*.jar', '*.jpg'] \
|
||||
'libprs500.lrf' : ['*.jar', '*.jpg'], \
|
||||
'libprs500.metadata' : ['*.pl'] \
|
||||
},
|
||||
entry_points = {
|
||||
'console_scripts': [ \
|
||||
@ -65,7 +74,7 @@ setup(
|
||||
'gui_scripts' : [ 'prs500-gui = libprs500.gui.main:main']
|
||||
},
|
||||
zip_safe = True,
|
||||
install_requires=["pyusb>=0.3.5", "pyxml>=0.8.4"],
|
||||
install_requires = install_requires,
|
||||
dependency_links = ["http://sourceforge.net/project/showfiles.php?group_id=6473",
|
||||
"http://easynews.dl.sourceforge.net/sourceforge/pyusb/pyusb-0.3.5.tar.gz",
|
||||
],
|
||||
|
@ -37,6 +37,6 @@ the following rule in C{/etc/udev/rules.d/90-local.rules} ::
|
||||
You may have to adjust the GROUP and the location of the rules file to
|
||||
suit your distribution.
|
||||
"""
|
||||
__version__ = "0.3.0b3"
|
||||
__version__ = "0.3.0b4"
|
||||
__docformat__ = "epytext"
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
|
@ -177,6 +177,8 @@ def ls(dev, path, term, recurse=False, color=False, human_readable_size=False, l
|
||||
def main():
|
||||
term = TerminalController()
|
||||
cols = term.COLS
|
||||
if not cols: # On windows terminal width is unknown
|
||||
cols = 80
|
||||
|
||||
parser = OptionParser(usage="usage: %prog [options] command args\n\ncommand is one of: info, books, df, ls, cp, mkdir, touch, cat, rm\n\n"+
|
||||
"For help on a particular command: %prog command", version="libprs500 version: " + VERSION)
|
||||
@ -302,3 +304,6 @@ def main():
|
||||
print >>sys.stderr, e
|
||||
return 1
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
20
src/libprs500/metadata/__init__.py
Normal file
20
src/libprs500/metadata/__init__.py
Normal file
@ -0,0 +1,20 @@
|
||||
## Copyright (C) 2006 Kovid Goyal kovid@kovidgoyal.net
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along
|
||||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
"""
|
||||
Provides metadata editing support for PDF and RTF files. For LRF metadata, use
|
||||
the L{libprs500.lrf.meta} module.
|
||||
"""
|
||||
__docformat__ = "epytext"
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
49
src/libprs500/metadata/pdf-meta.pl
Normal file
49
src/libprs500/metadata/pdf-meta.pl
Normal file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/perl
|
||||
# Read/Write PDF meta data
|
||||
# Based on pdf-meta from http://www.osresearch.net/wiki/index.php/Pdf-meta
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use PDF::API2;
|
||||
use Getopt::Long;
|
||||
use Data::Dumper;
|
||||
|
||||
my %new_info = (Creator => 'libprs500.metadata', CreationDate => scalar( localtime ),);
|
||||
|
||||
GetOptions(
|
||||
"c|creator=s" => \$new_info{Creator},
|
||||
"d|date=s" => \$new_info{CreationDate},
|
||||
"p|producer=s" => \$new_info{Producer},
|
||||
"a|author=s" => \$new_info{Author},
|
||||
"s|subject=s" => \$new_info{Subject},
|
||||
"k|keywords=s" => \$new_info{Keywords},
|
||||
"t|title=s" => \$new_info{Title},
|
||||
) or die "Usage: (no help yet!)\n";
|
||||
|
||||
|
||||
|
||||
for my $file (@ARGV)
|
||||
{
|
||||
my $pdf = PDF::API2->open( $file )
|
||||
or warn "Unable to open $file: $!\n"
|
||||
and next;
|
||||
|
||||
my %info = $pdf->info;
|
||||
for my $key (keys %info)
|
||||
{
|
||||
print $key.' = """'.$info{$key}.'"""'."\n";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
for my $key (keys %new_info)
|
||||
{
|
||||
my $new_value = $new_info{$key};
|
||||
next unless defined $new_value;
|
||||
|
||||
$info{$key} = $new_value;
|
||||
}
|
||||
|
||||
$pdf->info( %info );
|
||||
$pdf->saveas( $file );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user