Commit 4a02a621 authored by jcfp's avatar jcfp

Imported Debian patch 0.4.0-1

$Id: CHANGES,v 1.2 2004/02/18 23:05:05 cvs Exp $
version: 0.1
- Initial release.
......@@ -25,3 +22,15 @@ version: 0.3
- Encoded lines size now is 128 chars.
- using fread() instead of fgets in decode() function (much faster).
- SWIG isn't used anymore for wrapper generation.
version: 0.4
- change license to LGPL
- crc32 codes are now Python longs (returned from _yenc calls) in the range [2**0, 2**32 -1]
- crc32 formatting is fixed
- 'bytes' arguments named 'bytez' to avoid collision with 'bytes' type
- basic unit testing
- unescaped dots at the beginning of line caused ydecode to fail under some circumstances
dots at the beginning of line are now always escaped
- Encoder's and Decoder's output files (if any) are automatically flushed and closed upon deletion
- new method close() on Encoder and Decoder
This diff is collapsed.
CHANGES
COPYING
MANIFEST
MANIFEST.in
README
TODO
setup.cfg
setup.py
debian/changelog
debian/control
debian/rules
debian/DEBIAN/control
doc/yenc-draft.1.3.txt
examples/logo.ync
examples/ydecode.py
examples/ydecode_Decoder.py
examples/yencode.py
examples/yencode_Encoder.py
lib/yenc.py
src/_yenc.c
src/_yenc.h
test/test.py
Metadata-Version: 1.0
Name: yenc
Version: 0.3
Version: 0.3.1
Summary: yEnc Module for Python
Home-page: http://golug.cc.uniud.it/yenc.html
Home-page: http://www.golug.it/yenc.html
Author: Alessandro Duca
Author-email: dual@golug.cc.uniud.it
License: GPL
Author-email: alessandro.duca@gmail.com
License: LGPL
Description: UNKNOWN
Platform: UNKNOWN
$Id: README,v 1.2 2004/02/18 23:05:05 cvs Exp $
##=============================================================================
#
# Copyright (C) 2003, 2011 Alessandro Duca <alessandro.duca@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#=============================================================================
#
##=============================================================================
Description:
-----------
......@@ -14,30 +32,36 @@ input and output and use filenames instead of file objects as arguments
for encode() and decode() ). See CHANGES file for details.
Version 0.3 doesn't introduce anything new, just a bugfix a some internals
changes.
Version 0.4 introduces the close() method on Encoder and Decoder, fixes
crc32 formatting and adds escaping of '.' for compatibility with some ydecode
tools, strictly speaking this wasn't a bug and yenc specs reccomend this
behaviour only for clients that write directly on the tcp steam.
Version 0.4 is meant to be backward compatible with both 0.3 and 0.2.
Requirements:
------------
A C developement environment, Python>=2.1 and python developement libs (look for
A C developement environment, Python>=2.6 and python developement libs (look for
python-dev or something like that if you're using .rpm or .deb packages, if you
installed from sources you already have everything you need).
The module is known to work with Python2.1 and 2.2, maybe it will work also
with 1.5.2 (as long as you have distutils I think).
The module is known to work with Python2.6, testing with other version is needed.
Installation:
------------
To install:
tar xzfv yenc-0.3.tar.gz
cd yenc-0.3
tar xzfv yenc-0.4.tar.gz
cd yenc-0.4
python setup.py build
su
python setup.py install
To uninstall:
Simply remove _yenc.so, yenc.py and yenc.pyc from your PYTHONPATH.
On my Debian GNU/Linux 3.0:
/usr/local/lib/python2.2/site-packages/{_yenc.so,yenc.py,yenc.pyc}
On my Ubuntu:
/usr/local/lib/python2.6/site-packages/{_yenc.so,yenc.py,yenc.pyc}
Usage:
......@@ -77,7 +101,39 @@ output can't be written or calculated crc doesn't match the optional crc_in
argument (useful for writing decoding tools).
CRC32 sums are always represented as lowercase strings, whithout any
preceeding simbol ( like '0x').
preceeding simbol (like '0x').
Decoder and Encoder:
-------------------
Encoder and Decoder are facility classes meant for encoding data one chunk at time,
optionally writing the encoded/decoded data to an output file.
import yenc.Encoder
encoder = Encoder()
encoder.feed('some data')
encoder.feed('some other data')
encoder.terminate() # writes the \r\n terminator on file, further feed(..) will fail
encoded_data = encoder.getEncoded() # returns encoded data as string
crc32 = encoder.getCrc32() # returns crc32 of clear data
optionally you can write onto an output file:
encoder = Encoder(file('outputfile.ync', 'wb'))
encoder.feed('some data')
encoder.feed('some other data')
encoder.terminate()
encoder.flush() # writes the local buffer to the output file
encoder.close() # flushes and closes output_file, called automatically upon deletion
crc32 = encoder.getCrc32()
Decoder works basically the same way.
Performances:
......@@ -86,13 +142,13 @@ Fast enough.
Author:
------
Alessandro Duca <dual@golug.cc.uniud.it>
------:
Alessandro Duca <alessandro.duca AT gmail.com>
Thanks:
------
Michael Muller <mmuller@endunden.com> for code reviewing and fixing.
Michael Muller <mmuller AT endunden.com> for code reviewing and fixing.
Greets, Sandro.
......
$Id: TODO,v 1.2 2004/02/18 23:05:05 cvs Exp $
version 0.3:
version 0.4:
- Provide *real* documentation.
......
python-yenc (0.4.0-1) unstable; urgency=low
* New upstream release (Closes: #470712).
* New maintainer (Closes: #673948).
* Update watch file.
* Update copyright, license changed to LGPL.
* debian/rules:
+ replace entirely with dh sequencer.
+ switch to dh_python2.
* Switch to source format 3.0 (quilt) (Closes: #664294).
* Bump Standards-Version to 3.9.4.
-- JCF Ploemen (jcfp) <linux@jcf.pm> Wed, 29 May 2013 14:25:56 +0200
python-yenc (0.3+debian-2) unstable; urgency=low
* Add debian/watch.
......
Source: python-yenc
Homepage: http://www.golug.it/yenc.html
Section: python
Priority: extra
Maintainer: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
Build-Depends: debhelper (>= 5), dpatch, python-support (>= 0.4), python-all-dev
Standards-Version: 3.7.3
Homepage: http://www.hellanzb.com/
Priority: optional
Maintainer: JCF Ploemen (jcfp) <linux@jcf.pm>
Uploaders: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Build-Depends: debhelper (>= 9), python-all-dev (>= 2.6.6-3~)
Standards-Version: 3.9.4
X-Python-Version: >= 2.5
Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/python-yenc/trunk/
Vcs-Browser: http://anonscm.debian.org/viewvc/python-modules/packages/python-yenc/trunk/
Package: python-yenc
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
Provides: ${python:Provides}
Description: yEnc encoding/decoding extension for Python
The yEnc module provide a simple API for doing raw encoding/decoding of
yencoded binaries, mainly for retrieving or posting to the usenet.
This implementation is really simple and intended mainly as an exercise
to the author but is also significatively faster than any possible pure
Python implementation and it's being actually used by some Python nntp
clients out there.
The yEnc module provides a simple API for raw encoding/decoding of
yencoded binaries, mainly used when retrieving from or posting to
Usenet. It is significantly faster than any pure-Python
implementation.
This package was debianized by Adam Cécile (Le_Vert) <gandalf@le-vert.net> on
Wed, 11 Apr 2007 17:04:29 +0200.
Adopted 2013 by JCF Ploemen (jcfp) <linux@jcf.pm>
It was downloaded from http://www.hellanzb.com/
Upstream Author: Author: Hellanzb Team <http://www.hellanzb.com/>
Alessandro Duca <dual@golug.cc.uniud.it>
It was downloaded from http://www.golug.it/yenc.html
Copyright: (C) 2003, 2004 Alessandro Duca <dual@golug.cc.uniud.it>
Upstream Author:
Alessandro Duca <alessandro.duca@gmail.com>
Copyright:
Copyright (C) 2003, 2011 by Alessandro Duca <alessandro.duca@gmail.com>
License:
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This package 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 library 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
Lesser General Public License for more details.
This package 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 Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
You should have received a copy of the GNU General Public License
along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU Lesser General Public
License can be found in `/usr/share/common-licenses/LGPL-2.1'.
On Debian systems, the complete text of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL'.
The Debian packaging is (C) 2007, Adam Cécile (Le_Vert) <gandalf@le-vert.net>
and is licensed under the GPL, see above.
Upstream sources have been repacked to remove a "debian/" subdirectory
containing out-dated Debian packaging.
* debian/*
Copyright (C) 2007, 2008 by Adam Cécile (Le_Vert) <gandalf@le-vert.net>
Copyright (C) 2013 by JCF Ploemen (jcfp) <linux@jcf.pm>
License:
This package 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 package 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 package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU General Public
License can be found in `/usr/share/common-licenses/GPL-2'.
#! /bin/sh /usr/share/dpatch/dpatch-run
## 000-Handle_env_CFLAGS_var.dpatch
## by Adam Cécile (Le_Vert) <gandalf@le-vert.net>
##
## DP: Do not auto-probe CFLAGS, and use which are passed in environment.
@DPATCH@
diff -u python-yenc-0.3~debian/setup.py python-yenc-0.3~debian/setup.py.new
--- python-yenc-0.3~debian/setup.py 2007-04-11 17:30:42.000000000 +0200
+++ python-yenc-0.3~debian/setup.py.new 2007-04-11 17:35:25.000000000 +0200
@@ -28,6 +28,11 @@
from distutils.core import setup, Extension
+# We don't want any "auto-defined" CFLAGS
+from distutils import sysconfig
+sysconfig.get_config_vars()["CFLAGS"] = ''
+sysconfig.get_config_vars()["OPT"] = ''
+
setup(
name = "yenc",
version = "0.3",
@@ -38,6 +43,6 @@
license = "GPL",
package_dir = { '': 'lib' },
py_modules = ["yenc"],
- ext_modules = [Extension("_yenc",["src/_yenc.c"],extra_compile_args=["-O2","-g"])]
+ ext_modules = [Extension("_yenc",["src/_yenc.c"],extra_compile_args=[])]
)
000-Handle_env_CFLAGS_var
# use debian compiler flags only
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@
platforms = ["Unix"],
package_dir = { '': 'lib' },
py_modules = ["yenc"],
- ext_modules = [Extension("_yenc",["src/_yenc.c"],extra_compile_args=["-O2","-g"])],
+ ext_modules = [Extension("_yenc",["src/_yenc.c"],extra_compile_args=[])],
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 2.5",
01_use_debian_compiler_flags.diff
......@@ -3,56 +3,5 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# I *love* dpatch
include /usr/share/dpatch/dpatch.make
PYVERS = $(shell pyversions -rv)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
build: $(PYVERS:%=build-stamp-py%)
build-stamp-py%: patch-stamp
dh_testdir
CFLAGS="$(CFLAGS)" python$* setup.py build
touch $@
clean: unpatch
dh_testdir
dh_testroot
rm -rf build build-stamp*
dh_clean
install: install-prereqs $(PYVERS:%=install-stamp-py%)
install-prereqs:
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
install-stamp-py%:
python$* setup.py install --root $(CURDIR)/debian/python-yenc
binary-indep: build install
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs CHANGES
dh_installdocs
dh_installexamples
dh_pysupport
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
%:
dh $@ --with python2
version=3
opts=dversionmangle=s/\+debian// \
http://www.hellanzb.com/hellanzb-content/yenc-(.*).tar.gz
http://www.golug.it/pub/yenc/yenc-(.*).tar.gz
......@@ -127,6 +127,6 @@ Gv(
KrI<VCDBZ|wDV|Ȓ;"6+MZ-Cԫ,.4VP/[BYWL΍xH2+<6JlJ?6VPfkU=MKVY j=}
;ë\D*,^k>kU+(?M/WzmN"H7+\[Yi:P.-E.ٴ0K6.ImS]̙ +,k>>i ]_UOl]eDB]fb
%mmiB7*⸫@[.ʙlҫȬ2:*Bv=}rcYkN.XTtIUBl$Bz]llEm3b-7jyI,z17.,\qn8v@jo?kHj?2B)+
.RwԪxP򫄅FovBZKfPr?J\,7~!LouoB+B6m#lS܆MBP^Pe2>8ZfE8=}IJjCP߅AZWBkJJ+
]`Sx*BZS-:-$XyQ}`-+.JfV9M8R3.,\> `$]T]$<2:m32aJ.la5!`]V} !a1.*e
=nRwԪxP򫄅FovBZKfPr?J\,7~!LouoB+B6m#lS܆MBP^Pe2>8ZfE8=}IJjCP߅AZWBkJJ
+]`Sx*BZS-:-$XyQ}`-+.JfV9M8R3.,\> `$]T]$<2:m32aJ.la5!`]V} !a1.*e
=yend size=16335 crc32=547266c7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##=============================================================================
#
# Copyright (C) 2003, 2004 Alessandro Duca
# Copyright (C) 2003, 2011 Alessandro Duca <alessandro.duca@gmail.com>
#
# 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,
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#=============================================================================
#
# $Id: ydecode.py,v 1.2 2004/02/18 23:10:11 cvs Exp $
#
##=============================================================================
......@@ -36,7 +33,7 @@ CRC32_RE = re.compile(r"^.*? crc32=(\w+)")
def main():
if len(sys.argv) > 1:
file_in = open(sys.argv[1],"r")
file_in = open(sys.argv[1],"rb")
else:
file_in = sys.stdin
while 1:
......@@ -54,7 +51,7 @@ def main():
elif not line:
sys.stderr.write("err-critical: no valid =ybegin header found\n")
sys.exit(1)
file_out = open(name,"w")
file_out = open(name,"wb")
try:
dec, dec_crc = yenc.decode(file_in, file_out, size)
except yenc.Error, e:
......
#!/usr/bin/env python
## -*- coding: utf-8 -*-
##=============================================================================
#
# Copyright (C) 2003, 2004 Alessandro Duca
# Copyright (C) 2003, 2011 Alessandro Duca <alessandro.duca@gmail.com>
#
# 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,
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#=============================================================================
#
# $Id: ydecode_Decoder.py,v 1.1 2004/02/18 11:33:08 cvs Exp $
#
##=============================================================================
import yenc
import os
import sys
import re
import yenc
NAME_RE = re.compile(r"^.*? name=(.+?)\r\n$")
LINE_RE = re.compile(r"^.*? line=(\d{3}) .*$")
SIZE_RE = re.compile(r"^.*? size=(\d+) .*$")
......@@ -38,7 +35,7 @@ CRC32_RE = re.compile(r"^.*? crc32=(\w+)")
def main():
head_crc = trail_crc = ""
if len(sys.argv) > 1:
file_in = open(sys.argv[1],"r")
file_in = open(sys.argv[1],"rb")
else:
file_in = sys.stdin
while 1:
......@@ -56,7 +53,7 @@ def main():
elif not line:
sys.stderr.write("err-critical: no valid =ybegin header found\n")
sys.exit(1)
file_out = open(name,"w")
file_out = open(name,"wb")
dec = yenc.Decoder(file_out)
trailer = ""
garbage = 0
......@@ -70,11 +67,10 @@ def main():
else:
dec.feed(data)
dec.flush()
#file_out.write(dec.getDecoded())
if trailer:
try:
size = int( SIZE_RE.match(line).group(1) )
m_obj = CRC32_RE.match(line)
size = int(SIZE_RE.match(trailer).group(1))
m_obj = CRC32_RE.search(trailer)
if m_obj:
trail_crc = m_obj.group(1)
except re.error, e:
......@@ -90,7 +86,7 @@ def main():
else:
sys.exit(0)
# print "comparing"
if cmp(tmp_crc,dec.getCrc32()):
if cmp(tmp_crc, dec.getCrc32()):
sys.stderr.write("err: header: %s dec: %s CRC32 mismatch\n" % (tmp_crc,dec.getCrc32()) )
sys.exit(1)
else:
......
##!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##=============================================================================
#
# Copyright (C) 2003, 2004 Alessandro Duca
# Copyright (C) 2003, 2011 Alessandro Duca <alessandro.duca@gmail.com>
#
# 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,
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#=============================================================================
#
# $Id: yencode.py,v 1.2 2004/02/18 23:10:11 cvs Exp $
#
##=============================================================================
......@@ -40,26 +37,26 @@ def main():
file_out = sys.stdout
for o,a in opts:
if o == '-o':
file_out = open(a,"w")
file_out = open(a,"wb")
if args:
filename = args[0]
if os.access( filename, os.F_OK | os.R_OK ):
file_in = open(filename,"r")
file_in = open(filename,"rb")
else:
print "couldn't access %s" % filename
sys.exit(2)
else:
usage()
crc = hex( crc32( open(filename,"r").read() ) )[2:]
crc = "%08x"%(0xFFFFFFFF & crc32(open(filename,"rb").read()))
name = os.path.split(filename)[1]
size = os.stat(filename)[ST_SIZE]
file_out.write("=ybegin line=128 size=%d crc32=%s name=%s\r\n" % (size, crc, name) )
try:
encoded, crc = yenc.encode(file_in, file_out, size)
encoded, crc_out = yenc.encode(file_in, file_out, size)
except Exception, e:
print e
sys.exit(3)
file_out.write("=yend size=%d crc32=%s\r\n" % (encoded, crc) )
file_out.write("=yend size=%d crc32=%s\r\n" % (encoded, crc_out))
def usage():
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##=============================================================================
#
# Copyright (C) 2003, 2004 Alessandro Duca
# Copyright (C) 2003, 2011 Alessandro Duca <alessandro.duca@gmail.com>
#
# 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,
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#=============================================================================
#
# $Id: yencode_Encoder.py,v 1.2 2004/02/18 23:09:30 cvs Exp $
#
##=============================================================================
import sys
import os
import os.path
......@@ -41,21 +37,21 @@ def main():
file_out = sys.stdout
for o,a in opts:
if o == '-o':
file_out = open(a,"w")
file_out = open(a,"wb")
if args:
filename = args[0]
if os.access( filename, os.F_OK | os.R_OK ):
file_in = open(filename,"r")
file_in = open(filename,"rb")
else:
print "couldn't access %s" % filename
sys.exit(2)
else:
usage()
crc = hex( crc32( open(filename,"r").read() ) )[2:]
crc = "%x"%(0xFFFFFFFF & crc32( open(filename,"rb").read()))
name = os.path.split(filename)[1]
size = os.stat(filename)[ST_SIZE]
file_out.write("=ybegin line=128 size=%d crc32=%s name=%s\r\n" % (size, crc, name) )
file_in = open(filename, "r")
file_in = open(filename, "rb")
encoder = yenc.Encoder(file_out)
while True:
data_in = file_in.read(1024)
......@@ -68,7 +64,7 @@ def main():
def usage():
print "Usage: yencode2.py <-o outfile> filename"
print "Usage: yencode_Encoder.py <-o outfile> filename"
sys.exit(1)
if __name__ == "__main__":
......