Skip to content

Commit

Permalink
v0.2.1: terrible bug.
Browse files Browse the repository at this point in the history
Signed-off-by: Kwpolska <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Aug 13, 2012
1 parent d56ed0c commit 1ab3ffd
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 35 deletions.
4 changes: 2 additions & 2 deletions PKGBUILD
@@ -1,6 +1,6 @@
# Maintainer: Kwpolska <kwpolska@kwpolska.tk>
pkgname=trashman
pkgver=0.2.0
pkgver=0.2.1
pkgrel=1
pkgdesc='A Python XDG trash manager. (built under py3k)'
arch=('any')
Expand All @@ -9,7 +9,7 @@ license=('BSD')
depends=('python')
options=(!emptydirs)
source=("http://pypi.python.org/packages/source/t/${pkgname}/${pkgname}-${pkgver}.tar.gz")
md5sums=('acb9613c9db9585ca88c5efbd5706207')
md5sums=('a37099d36ae0dcecfaf920e505c73cf7')

package() {
cd "${srcdir}/${pkgname}-${pkgver}"
Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -5,7 +5,7 @@ Trashman. A Python XDG trash manager.
:Info: This is the README file for Trashman.
:Author: Kwpolska <kwpolska@kwpolska.tk>
:Date: 2012-08-13
:Version: 0.2.0
:Version: 0.2.1

PURPOSE
-------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -5,7 +5,7 @@ Trashman. A Python XDG trash manager.
:Info: This is the README file for Trashman.
:Author: Kwpolska <kwpolska@kwpolska.tk>
:Date: 2012-08-13
:Version: 0.2.0
:Version: 0.2.1

PURPOSE
-------
Expand Down
4 changes: 1 addition & 3 deletions TODO.rst
Expand Up @@ -17,10 +17,8 @@ TODO for Trashman:
(created a directory called ~/Desktop/TRASHTEST, added a file,
trashed the directory, tried to restore the file inside)

* manpage
requires: .rst, ./release modifications (stel from pkgbuilder)

* [proposition] file management UI
requires: magic, qt/ncurses (ranger is in python, this might be of use)
NOTE: don’t forget that ncurses = pure evil!

-- Kwpolska 2012-08-10T18:53:00Z
2 changes: 1 addition & 1 deletion docs/LICENSE.rst
Expand Up @@ -4,7 +4,7 @@ Appendix A. License for Trashman
:Info: This is an appendix to the Trashman documentation.
:Author: Kwpolska <kwpolska@kwpolska.tk>
:Date: 2012-08-13
:Version: 0.2.0
:Version: 0.2.1

.. index:: LICENSE

Expand Down
2 changes: 1 addition & 1 deletion docs/README.rst
Expand Up @@ -5,7 +5,7 @@ Trashman. A Python XDG trash manager.
:Info: This is the README file for Trashman.
:Author: Kwpolska <kwpolska@kwpolska.tk>
:Date: 2012-08-13
:Version: 0.2.0
:Version: 0.2.1

PURPOSE
-------
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -49,9 +49,9 @@
# built documents.
#
# The short X.Y version.
version = '0.2.0'
version = '0.2.1'
# The full version, including alpha/beta/rc tags.
release = '0.2.0'
release = '0.2.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/functions.rst
Expand Up @@ -4,7 +4,7 @@ Functions List
:Author: Kwpolska
:Copyright: See Appendix A.
:Date: 2012-08-13
:Version: 0.2.0
:Version: 0.2.1

.. index:: functions

Expand Down
Binary file modified docs/trashman.8.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/trashman.rst
Expand Up @@ -5,7 +5,7 @@ Trashman
:Author: Kwpolska <kwpolska@kwpolska.tk>
:Copyright: See Appendix A.
:Date: 2012-08-13
:Version: 0.2.0
:Version: 0.2.1
:Manual section: 1
:Manual group: Trashman manual

Expand Down
43 changes: 43 additions & 0 deletions release
Expand Up @@ -30,6 +30,49 @@ rm docs/trashman.8.gz | true
rst2man docs/trashman.rst > docs/trashman.8
gzip docs/trashman.8

xgettext -c trashman.py -o ./messages.pot

sed '1,+17d' ./messages.pot > ./messages.pot.tmp

pot='# Trashman pot file.
# Copyright (C) 2011-2012, Kwpolska.
# This file is distributed under the same license as the Trashman package.
# Kwpolska <kwpolska@kwpolska.tk>, 2011-2012.
#
msgid ""
msgstr ""
"Project-Id-Version: #version\\n"
"Report-Msgid-Bugs-To: Kwpolska <kwpolska@kwpolska.tk>\\n"
"POT-Creation-Date: #datel\\n"
"PO-Revision-Date: #datel\\n"
"Last-Translator: Kwpolska <kwpolska@kwpolska.tk>\\n"
"Language-Team: Kwpolska <kwpolska@kwpolska.tk>\\n"
"Language: en\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"'

echo $pot > messages.pot
cat ./messages.pot.tmp >> messages.pot
rm ./messages.pot.tmp

sed "s/#version/$version/g" messages.pot -i
sed "s/#datel/$datel/g" messages.pot -i

for i in ./locale/*; do
language=$(basename $i)

podir="./locale/$language/LC_MESSAGES"
popath="./locale/$language/LC_MESSAGES/trashman.po"
sed 's/\"Project-Id-Version: .*/\"Project-Id-Version: '$version'\\n\"/' $popath -i
msgmerge $popath messages.pot -o $popath
fuzzy=$(cat $popath | grep '#, fuzzy')
echo "Please press a key to validate language $language."
read validatesure
$EDITOR $popath
msgfmt -o $podir/trashman.mo $popath
done

python -c 'import trashman'
if [[ $? = 1 ]]; then
echo "Import failed. Fix your code or don't come back."
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Expand Up @@ -4,10 +4,9 @@
from setuptools import setup
except ImportError:
from distutils.core import setup
#from distutils.core import setup

setup(name='trashman',
version='0.2.0',
version='0.2.1',
description='A Python XDG trash manager.',
author='Kwpolska',
author_email='kwpolska@kwpolska.tk',
Expand All @@ -25,4 +24,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Utilities'],
scripts=['bin/trash'])
py_modules = ['trashman'],
scripts=['bin/trash'],
data_files=[('share/man/man8', ['docs/pkgbuilder.8.gz'])])
48 changes: 29 additions & 19 deletions trashman.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Trashman v0.2.0
# Trashman v0.2.1
# A Python XDG trash manager.
# Copyright (C) 2011-2012, Kwpolska.
# All rights reserved.
#
Expand Down Expand Up @@ -34,7 +35,11 @@
"""
trashman
~~~~~~~~
A Python XDG Trash manager.
A Python XDG trash manager.
:Copyright: (C) 2011-2012, Kwpolska.
:License: BSD (see /LICENSE).
"""

import shutil
Expand All @@ -44,6 +49,7 @@
import datetime
import sys
import argparse
import gettext

try:
import configparser
Expand All @@ -55,8 +61,11 @@
else:
trash = os.getenv('XDG_DATA_HOME') + '/Trash'

T = gettext.translation('trashman', '/usr/share/locale', fallback='C')
_ = T.gettext

__title__ = 'Trashman'
__version__ = '0.2.0'
__version__ = '0.2.1'
__author__ = 'Kwpolska'
__license__ = '3-clause BSD'

Expand Down Expand Up @@ -104,7 +113,7 @@ def empty_trash(verbose):
shutil.rmtree(trash + '/info')
regenerate_trash()
if verbose:
sys.stderr.write("emptied the trash\n")
sys.stderr.write(_("emptied the trash\n"))


def list_files():
Expand Down Expand Up @@ -144,7 +153,7 @@ def move_to_trash(filepath, verbose):
regenerate_trash()

if verbose:
sys.stderr.write("trashed ‘{0}’\n".format(filename))
sys.stderr.write(_("trashed ‘{0}’\n").format(filename))


def restore_from_trash(filename, verbose):
Expand All @@ -156,40 +165,41 @@ def restore_from_trash(filename, verbose):
os.remove(trash + '/info/' + filename + '.trashinfo')
regenerate_trash()
if verbose:
sys.stderr.write('restored {0} to {1} (trashed {2})\n'.format(
filename, info['Path'], info['DeletionDate']))
sys.stderr.write(_('restored {0} to {1} (trashed {2})\n'.format(
filename, info['Path'], info['DeletionDate'])))
else:
raise Exception('no such file in trash')


def main():
"""The main routine."""
parser = argparse.ArgumentParser(description="Trashman – a Python XDG \
trash manager.")
parser = argparse.ArgumentParser(description=_("Trashman – a Python \
XDG trash manager."))

parser.add_argument('-V', '--version', action='version',
version='Trashman v' + __version__)
parser.add_argument('-v', '--verbose', action='store_true', default=False,
dest='verbose', help="explain what is being done")
dest='verbose', help=_("explain what is being done"))
parser.add_argument('-e', '--empty', action='store_true', default=False,
dest='empty', help="empty the trash and quit")
dest='empty', help=_("empty the trash and quit"))
parser.add_argument('-l', '--list', action='store_true', default=False,
dest='flist', help="list the files in trash and quit")
dest='flist', help=_("list the files in trash and \
quit"))
parser.add_argument('-r', '--restore', action='store_true', default=False,
dest='restore', help="restore FILE(s) from trash")
dest='restore', help=_("restore FILE(s) from trash"))
parser.add_argument('-w', '--trash-location', action='store_true',
default=False, dest='showloc', help="print the \
trash location and quit")
parser.add_argument('files', metavar="FILE", action='store', nargs='*',
help="files to remove")
default=False, dest='showloc', help=_("print the \
trash location and quit"))
parser.add_argument('files', metavar=_("FILE"), action='store', nargs='*',
help=_("files to remove"))
args = parser.parse_args()

quit_notrash = False

if not os.path.exists(trash):
if args.verbose:
sys.stderr.write("“{0}” does not exist, creating...".format(
trash))
sys.stderr.write(_("“{0}” does not exist, \
creating...").format(trash))

regenerate_trash()

Expand Down

0 comments on commit 1ab3ffd

Please sign in to comment.