/snap/core18/2999/usr/bin
NameSizeModeActions
aa-enabled226960755editdlrm
aa-exec226960755editdlrm
addpart226080755editdlrm
apt770755editdlrm
apt-cache770755editdlrm
apt-get770755editdlrm
arch350320755editdlrm
awk1254160755editdlrm
b2sum555120755editdlrm
base32390960755editdlrm
base64390960755editdlrm
basename350000755editdlrm
bashbug71150755editdlrm
bootctl349520755editdlrm
busctl676720755editdlrm
captoinfo840800755editdlrm
catchsegv33340755editdlrm
cautious-launcher8530755editdlrm
chage718162755editdlrm
chardet33890755editdlrm
chardetect33890755editdlrm
chattr143360755editdlrm
chcon636720755editdlrm
chfn764964755editdlrm
chrt308000755editdlrm
chsh445284755editdlrm
cksum350000755editdlrm
clear102400755editdlrm
clear_console103120755editdlrm
cloud-id3960755editdlrm
cloud-init4000755editdlrm
cloud-init-per21080755editdlrm
cmp472000755editdlrm
comm391280755editdlrm
compose181610755editdlrm
console-conf29310755editdlrm
core-sshd-host-keygen15650755editdlrm
csplit514160755editdlrm
ctstat228880755editdlrm
cut432240755editdlrm
c_rehash68060755editdlrm
dbus-cleanup-sockets102240755editdlrm
dbus-daemon2365840755editdlrm
dbus-monitor225200755editdlrm
dbus-run-session102240755editdlrm
dbus-send266080755editdlrm
dbus-update-activation-environment143200755editdlrm
dbus-uuidgen102240755editdlrm
deb-systemd-helper201420755editdlrm
deb-systemd-invoke44340755editdlrm
delpart226080755editdlrm
dh_bash-completion25500755editdlrm
diff1457520755editdlrm
diff3637040755editdlrm
dircolors472960755editdlrm
dirname309040755editdlrm
dpkg-deb1539520755editdlrm
du1005680755editdlrm
ec2metadata72970755editdlrm
edit181610755editdlrm
editor11121520755editdlrm
env350000755editdlrm
ex11121520755editdlrm
expand391280755editdlrm
expiry228082755editdlrm
expr472880755editdlrm
factor759920755editdlrm
faillog187280755editdlrm
fallocate267040755editdlrm
finalrd21520755editdlrm
find2380800755editdlrm
flock308800755editdlrm
fmt431920755editdlrm
fold350000755editdlrm
free185120755editdlrm
gdbserver6610160755editdlrm
getconf308560755editdlrm
getent312240755editdlrm
getopt144080755editdlrm
gpasswd758244755editdlrm
gpgv4413600755editdlrm
groups350000755editdlrm
growpart218830755editdlrm
head432240755editdlrm
helpztags25140755editdlrm
hostid309040755editdlrm
hostnamectl185040755editdlrm
i386187840755editdlrm
iconv637440755editdlrm
id432240755editdlrm
infocmp594640755editdlrm
infotocap840800755editdlrm
install1456640755editdlrm
ionice267040755editdlrm
ipcmk267680755editdlrm
ipcrm267040755editdlrm
ipcs512800755editdlrm
iptables-xml-0editdlrm
ischroot102800755editdlrm
join473200755editdlrm
jsondiff10180755editdlrm
jsonpatch36610755editdlrm
jsonpointer13420755editdlrm
jsonschema3980755editdlrm
kernel-install45080755editdlrm
last430880755editdlrm
lastb430880755editdlrm
lastlog185040755editdlrm
lcf77860755editdlrm
ldd54270755editdlrm
less1800640755editdlrm
lessecho146560755editdlrm
lessfile85640755editdlrm
lesskey242880755editdlrm
lesspipe85640755editdlrm
link309040755editdlrm
linux32187840755editdlrm
linux64187840755editdlrm
lnstat228880755editdlrm
locale505920755editdlrm
locale-check102400755editdlrm
localectl226000755editdlrm
localedef3387440755editdlrm
logger477920755editdlrm
logname309040755editdlrm
lsattr102400755editdlrm
lscpu717600755editdlrm
lsipc717600755editdlrm
lslocks352320755editdlrm
lslogins635680755editdlrm
lsmem430880755editdlrm
lsns389920755editdlrm
mawk1254160755editdlrm
mcookie308640755editdlrm
md5sum432240755editdlrm
md5sum.textutils432240755editdlrm
mesg103120755editdlrm
miniterm350980755editdlrm
mkfifo636720755editdlrm
mksquashfs1894320755editdlrm
mkswapfile8650755editdlrm
namei267040755editdlrm
nawk1254160755editdlrm
newgrp403444755editdlrm
nice350000755editdlrm
nl432880755editdlrm
no-apt770755editdlrm
nohup350000755editdlrm
nproc350000755editdlrm
nsenter310080755editdlrm
nstat266960755editdlrm
numfmt637360755editdlrm
od678000755editdlrm
openssl7239440755editdlrm
pager1707600755editdlrm
partx881440755editdlrm
passwd596404755editdlrm
paste350320755editdlrm
pathchk350000755editdlrm
pdb3613100755editdlrm
pdb3.6613100755editdlrm
perl20977200755editdlrm
perl5.26.120977200755editdlrm
pgrep267120755editdlrm
pinky391280755editdlrm
pkill267120755editdlrm
pldd145600755editdlrm
pmap308080755editdlrm
pr719600755editdlrm
print181610755editdlrm
printenv309040755editdlrm
printf513840755editdlrm
prlimit354240755editdlrm
probert21430755editdlrm
ptx719280755editdlrm
pwdx103120755editdlrm
py3clean78120755editdlrm
py3compile121190755editdlrm
py3versions117170755editdlrm
pydoc3790755editdlrm
pydoc3.6790755editdlrm
pygettext3215470755editdlrm
pygettext3.6215470755editdlrm
pyjwt33720755editdlrm
python345305840755editdlrm
python3-jsondiff10180755editdlrm
python3-jsonpatch36610755editdlrm
python3-jsonpointer13420755editdlrm
python3-jsonschema3980755editdlrm
python3.645305840755editdlrm
python3.6m45305840755editdlrm
python3m45305840755editdlrm
rcp1004960755editdlrm
rdma266960755editdlrm
realpath473200755editdlrm
rename.ul144080755editdlrm
renice144080755editdlrm
reset225280755editdlrm
resizepart389920755editdlrm
rev103120755editdlrm
rgrep300755editdlrm
rlogin7278480755editdlrm
routef2080755editdlrm
routel16560755editdlrm
rsh7278480755editdlrm
rtstat228880755editdlrm
run-mailcap181610755editdlrm
runcon350000755editdlrm
rview11121520755editdlrm
savelog104690755editdlrm
scp1004960755editdlrm
script307920755editdlrm
scriptreplay267040755editdlrm
sdiff512960755editdlrm
see181610755editdlrm
select-editor24420755editdlrm
sensible-browser12090755editdlrm
sensible-editor11090755editdlrm
sensible-pager4330755editdlrm
seq472880755editdlrm
setarch187840755editdlrm
setsid103120755editdlrm
setterm430880755editdlrm
sftp1539600755editdlrm
sg403444755editdlrm
sha1sum473200755editdlrm
sha224sum555120755editdlrm
sha256sum555120755editdlrm
sha384sum596080755editdlrm
sha512sum596080755editdlrm
shred596080755editdlrm
shuf554800755editdlrm
skill267040755editdlrm
slabtop185120755editdlrm
slogin7278480755editdlrm
snap236585690755editdlrm
snapctl-0editdlrm
snice267040755editdlrm
sort1131200755editdlrm
split559360755editdlrm
ssh7278480755editdlrm
ssh-add3462480755editdlrm
ssh-agent3626402755editdlrm
ssh-argv014560755editdlrm
ssh-copy-id106580755editdlrm
ssh-keygen4200000755editdlrm
ssh-keyscan4240960755editdlrm
stat800880755editdlrm
stdbuf472880755editdlrm
sudo1490804755editdlrm
sudoedit1490804755editdlrm
sudoreplay561280755editdlrm
sum391040755editdlrm
systemd-analyze15628880755editdlrm
systemd-cat103120755editdlrm
systemd-cgls144080755editdlrm
systemd-cgtop308160755editdlrm
systemd-delta226000755editdlrm
systemd-detect-virt103040755editdlrm
systemd-mount431040755editdlrm
systemd-path103040755editdlrm
systemd-resolve881360755editdlrm
systemd-run430800755editdlrm
systemd-socket-activate185040755editdlrm
systemd-stdio-bridge144080755editdlrm
systemd-umount431040755editdlrm
tabs143280755editdlrm
tac390960755editdlrm
tail678320755editdlrm
taskset308000755editdlrm
tee350320755editdlrm
test472880755editdlrm
tic840800755editdlrm
timedatectl8150755editdlrm
timedatectl.real226000755editdlrm
timeout395520755editdlrm
tload144240755editdlrm
toe143280755editdlrm
top1083040755editdlrm
touch1007280755editdlrm
tput184560755editdlrm
tr472880755editdlrm
truncate390960755editdlrm
tset225280755editdlrm
tsort350000755editdlrm
tty309040755editdlrm
tzselect154020755editdlrm
ucf406850755editdlrm
ucfq193670755editdlrm
ucfr107220755editdlrm
unexpand391280755editdlrm
uniq432240755editdlrm
unlink309040755editdlrm
unshare187120755editdlrm
unsquashfs1021040755editdlrm
update-alternatives471120755editdlrm
uptime103120755editdlrm
users350000755editdlrm
utmpdump226000755editdlrm
vcs-run69130755editdlrm
vi11121520755editdlrm
view11121520755editdlrm
vim.tiny11121520755editdlrm
vmstat349120755editdlrm
w185040755editdlrm
w.procps185040755editdlrm
wall308002755editdlrm
watch229520755editdlrm
wc432000755editdlrm
whereis271440755editdlrm
which9460755editdlrm
who514160755editdlrm
whoami309040755editdlrm
wpa_passphrase634880755editdlrm
x86_64187840755editdlrm
xargs718960755editdlrm
xdg-open380755editdlrm
xdg-settings17230755editdlrm
xxd185520755editdlrm
yes309040755editdlrm
zdump184880755editdlrm
[513840755editdlrm
Edit: /snap/core18/2999/usr/bin/pygettext3.6 (21547B)
#! /usr/bin/python3.6 # -*- coding: iso-8859-1 -*- # Originally written by Barry Warsaw # # Minimally patched to make it even more xgettext compatible # by Peter Funk # # 2002-11-22 Jürgen Hermann # Added checks that _() only contains string literals, and # command line args are resolved to module lists, i.e. you # can now pass a filename, a module or package name, or a # directory (including globbing chars, important for Win32). # Made docstring fit in 80 chars wide displays using pydoc. # # for selftesting try: import fintl _ = fintl.gettext except ImportError: _ = lambda s: s __doc__ = _("""pygettext -- Python equivalent of xgettext(1) Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the internationalization of C programs. Most of these tools are independent of the programming language and can be used from within Python programs. Martin von Loewis' work[1] helps considerably in this regard. There's one problem though; xgettext is the program that scans source code looking for message strings, but it groks only C (or C++). Python introduces a few wrinkles, such as dual quoting characters, triple quoted strings, and raw strings. xgettext understands none of this. Enter pygettext, which uses Python's standard tokenize module to scan Python source code, generating .pot files identical to what GNU xgettext[2] generates for C and C++ code. From there, the standard GNU tools can be used. A word about marking Python strings as candidates for translation. GNU xgettext recognizes the following keywords: gettext, dgettext, dcgettext, and gettext_noop. But those can be a lot of text to include all over your code. C and C++ have a trick: they use the C preprocessor. Most internationalized C source includes a #define for gettext() to _() so that what has to be written in the source is much less. Thus these are both translatable strings: gettext("Translatable String") _("Translatable String") Python of course has no preprocessor so this doesn't work so well. Thus, pygettext searches only for _() by default, but see the -k/--keyword flag below for how to augment this. [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html [2] http://www.gnu.org/software/gettext/gettext.html NOTE: pygettext attempts to be option and feature compatible with GNU xgettext where ever possible. However some options are still missing or are not fully implemented. Also, xgettext's use of command line switches with option arguments is broken, and in these cases, pygettext just defines additional switches. Usage: pygettext [options] inputfile ... Options: -a --extract-all Extract all strings. -d name --default-domain=name Rename the default output file from messages.pot to name.pot. -E --escape Replace non-ASCII characters with octal escape sequences. -D --docstrings Extract module, class, method, and function docstrings. These do not need to be wrapped in _() markers, and in fact cannot be for Python to consider them docstrings. (See also the -X option). -h --help Print this help message and exit. -k word --keyword=word Keywords to look for in addition to the default set, which are: %(DEFAULTKEYWORDS)s You can have multiple -k flags on the command line. -K --no-default-keywords Disable the default set of keywords (see above). Any keywords explicitly added with the -k/--keyword option are still recognized. --no-location Do not write filename/lineno location comments. -n --add-location Write filename/lineno location comments indicating where each extracted string is found in the source. These lines appear before each msgid. The style of comments is controlled by the -S/--style option. This is the default. -o filename --output=filename Rename the default output file from messages.pot to filename. If filename is `-' then the output is sent to standard out. -p dir --output-dir=dir Output files will be placed in directory dir. -S stylename --style stylename Specify which style to use for location comments. Two styles are supported: Solaris # File: filename, line: line-number GNU #: filename:line The style name is case insensitive. GNU style is the default. -v --verbose Print the names of the files being processed. -V --version Print the version of pygettext and exit. -w columns --width=columns Set width of output to columns. -x filename --exclude-file=filename Specify a file that contains a list of strings that are not be extracted from the input files. Each string to be excluded must appear on a line by itself in the file. -X filename --no-docstrings=filename Specify a file that contains a list of files (one per line) that should not have their docstrings extracted. This is only useful in conjunction with the -D option above. If `inputfile' is -, standard input is read. """) import os import importlib.machinery import importlib.util import sys import glob import time import getopt import token import tokenize __version__ = '1.5' default_keywords = ['_'] DEFAULTKEYWORDS = ', '.join(default_keywords) EMPTYSTRING = '' # The normal pot-file header. msgmerge and Emacs's po-mode work better if it's # there. pot_header = _('''\ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR ORGANIZATION # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\\n" "POT-Creation-Date: %(time)s\\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" "Last-Translator: FULL NAME \\n" "Language-Team: LANGUAGE \\n" "MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=%(charset)s\\n" "Content-Transfer-Encoding: %(encoding)s\\n" "Generated-By: pygettext.py %(version)s\\n" ''') def usage(code, msg=''): print(__doc__ % globals(), file=sys.stderr) if msg: print(msg, file=sys.stderr) sys.exit(code) def make_escapes(pass_nonascii): global escapes, escape if pass_nonascii: # Allow non-ascii characters to pass through so that e.g. 'msgid # "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise we # escape any character outside the 32..126 range. mod = 128 escape = escape_ascii else: mod = 256 escape = escape_nonascii escapes = [r"\%03o" % i for i in range(mod)] for i in range(32, 127): escapes[i] = chr(i) escapes[ord('\\')] = r'\\' escapes[ord('\t')] = r'\t' escapes[ord('\r')] = r'\r' escapes[ord('\n')] = r'\n' escapes[ord('\"')] = r'\"' def escape_ascii(s, encoding): return ''.join(escapes[ord(c)] if ord(c) < 128 else c for c in s) def escape_nonascii(s, encoding): return ''.join(escapes[b] for b in s.encode(encoding)) def is_literal_string(s): return s[0] in '\'"' or (s[0] in 'rRuU' and s[1] in '\'"') def safe_eval(s): # unwrap quotes, safely return eval(s, {'__builtins__':{}}, {}) def normalize(s, encoding): # This converts the various Python string types into a format that is # appropriate for .po files, namely much closer to C style. lines = s.split('\n') if len(lines) == 1: s = '"' + escape(s, encoding) + '"' else: if not lines[-1]: del lines[-1] lines[-1] = lines[-1] + '\n' for i in range(len(lines)): lines[i] = escape(lines[i], encoding) lineterm = '\\n"\n"' s = '""\n"' + lineterm.join(lines) + '"' return s def containsAny(str, set): """Check whether 'str' contains ANY of the chars in 'set'""" return 1 in [c in str for c in set] def getFilesForName(name): """Get a list of module files for a filename, a module or package name, or a directory. """ if not os.path.exists(name): # check for glob chars if containsAny(name, "*?[]"): files = glob.glob(name) list = [] for file in files: list.extend(getFilesForName(file)) return list # try to find module or package try: spec = importlib.util.find_spec(name) name = spec.origin except ImportError: name = None if not name: return [] if os.path.isdir(name): # find all python files in directory list = [] # get extension for python source files _py_ext = importlib.machinery.SOURCE_SUFFIXES[0] for root, dirs, files in os.walk(name): # don't recurse into CVS directories if 'CVS' in dirs: dirs.remove('CVS') # add all *.py files to list list.extend( [os.path.join(root, file) for file in files if os.path.splitext(file)[1] == _py_ext] ) return list elif os.path.exists(name): # a single file return [name] return [] class TokenEater: def __init__(self, options): self.__options = options self.__messages = {} self.__state = self.__waiting self.__data = [] self.__lineno = -1 self.__freshmodule = 1 self.__curfile = None self.__enclosurecount = 0 def __call__(self, ttype, tstring, stup, etup, line): # dispatch ## import token ## print('ttype:', token.tok_name[ttype], 'tstring:', tstring, ## file=sys.stderr) self.__state(ttype, tstring, stup[0]) def __waiting(self, ttype, tstring, lineno): opts = self.__options # Do docstring extractions, if enabled if opts.docstrings and not opts.nodocstrings.get(self.__curfile): # module docstring? if self.__freshmodule: if ttype == tokenize.STRING and is_literal_string(tstring): self.__addentry(safe_eval(tstring), lineno, isdocstring=1) self.__freshmodule = 0 elif ttype not in (tokenize.COMMENT, tokenize.NL): self.__freshmodule = 0 return # class or func/method docstring? if ttype == tokenize.NAME and tstring in ('class', 'def'): self.__state = self.__suiteseen return if ttype == tokenize.NAME and tstring in opts.keywords: self.__state = self.__keywordseen def __suiteseen(self, ttype, tstring, lineno): # skip over any enclosure pairs until we see the colon if ttype == tokenize.OP: if tstring == ':' and self.__enclosurecount == 0: # we see a colon and we're not in an enclosure: end of def self.__state = self.__suitedocstring elif tstring in '([{': self.__enclosurecount += 1 elif tstring in ')]}': self.__enclosurecount -= 1 def __suitedocstring(self, ttype, tstring, lineno): # ignore any intervening noise if ttype == tokenize.STRING and is_literal_string(tstring): self.__addentry(safe_eval(tstring), lineno, isdocstring=1) self.__state = self.__waiting elif ttype not in (tokenize.NEWLINE, tokenize.INDENT, tokenize.COMMENT): # there was no class docstring self.__state = self.__waiting def __keywordseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == '(': self.__data = [] self.__lineno = lineno self.__state = self.__openseen else: self.__state = self.__waiting def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then just ignore this entry. if self.__data: self.__addentry(EMPTYSTRING.join(self.__data)) self.__state = self.__waiting elif ttype == tokenize.STRING and is_literal_string(tstring): self.__data.append(safe_eval(tstring)) elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL]: # warn if we see anything else than STRING or whitespace print(_( '*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"' ) % { 'token': tstring, 'file': self.__curfile, 'lineno': self.__lineno }, file=sys.stderr) self.__state = self.__waiting def __addentry(self, msg, lineno=None, isdocstring=0): if lineno is None: lineno = self.__lineno if not msg in self.__options.toexclude: entry = (self.__curfile, lineno) self.__messages.setdefault(msg, {})[entry] = isdocstring def set_filename(self, filename): self.__curfile = filename self.__freshmodule = 1 def write(self, fp): options = self.__options timestamp = time.strftime('%Y-%m-%d %H:%M%z') encoding = fp.encoding if fp.encoding else 'UTF-8' print(pot_header % {'time': timestamp, 'version': __version__, 'charset': encoding, 'encoding': '8bit'}, file=fp) # Sort the entries. First sort each particular entry's keys, then # sort all the entries by their first item. reverse = {} for k, v in self.__messages.items(): keys = sorted(v.keys()) reverse.setdefault(tuple(keys), []).append((k, v)) rkeys = sorted(reverse.keys()) for rkey in rkeys: rentries = reverse[rkey] rentries.sort() for k, v in rentries: # If the entry was gleaned out of a docstring, then add a # comment stating so. This is to aid translators who may wish # to skip translating some unimportant docstrings. isdocstring = any(v.values()) # k is the message string, v is a dictionary-set of (filename, # lineno) tuples. We want to sort the entries in v first by # file name and then by line number. v = sorted(v.keys()) if not options.writelocations: pass # location comments are different b/w Solaris and GNU: elif options.locationstyle == options.SOLARIS: for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} print(_( '# File: %(filename)s, line: %(lineno)d') % d, file=fp) elif options.locationstyle == options.GNU: # fit as many locations on one line, as long as the # resulting line length doesn't exceed 'options.width' locline = '#:' for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} s = _(' %(filename)s:%(lineno)d') % d if len(locline) + len(s) <= options.width: locline = locline + s else: print(locline, file=fp) locline = "#:" + s if len(locline) > 2: print(locline, file=fp) if isdocstring: print('#, docstring', file=fp) print('msgid', normalize(k, encoding), file=fp) print('msgstr ""\n', file=fp) def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:X:', ['extract-all', 'default-domain=', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstrings', 'no-docstrings', ]) except getopt.error as msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults extractall = 0 # FIXME: currently this option has no effect at all. escape = 0 keywords = [] outpath = '' outfile = 'messages.pot' writelocations = 1 locationstyle = GNU verbose = 0 width = 78 excludefilename = '' docstrings = 0 nodocstrings = {} options = Options() locations = {'gnu' : options.GNU, 'solaris' : options.SOLARIS, } # parse options for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-a', '--extract-all'): options.extractall = 1 elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot' elif opt in ('-E', '--escape'): options.escape = 1 elif opt in ('-D', '--docstrings'): options.docstrings = 1 elif opt in ('-k', '--keyword'): options.keywords.append(arg) elif opt in ('-K', '--no-default-keywords'): default_keywords = [] elif opt in ('-n', '--add-location'): options.writelocations = 1 elif opt in ('--no-location',): options.writelocations = 0 elif opt in ('-S', '--style'): options.locationstyle = locations.get(arg.lower()) if options.locationstyle is None: usage(1, _('Invalid value for --style: %s') % arg) elif opt in ('-o', '--output'): options.outfile = arg elif opt in ('-p', '--output-dir'): options.outpath = arg elif opt in ('-v', '--verbose'): options.verbose = 1 elif opt in ('-V', '--version'): print(_('pygettext.py (xgettext for Python) %s') % __version__) sys.exit(0) elif opt in ('-w', '--width'): try: options.width = int(arg) except ValueError: usage(1, _('--width argument must be an integer: %s') % arg) elif opt in ('-x', '--exclude-file'): options.excludefilename = arg elif opt in ('-X', '--no-docstrings'): fp = open(arg) try: while 1: line = fp.readline() if not line: break options.nodocstrings[line[:-1]] = 1 finally: fp.close() # calculate escapes make_escapes(not options.escape) # calculate all keywords options.keywords.extend(default_keywords) # initialize list of strings to exclude if options.excludefilename: try: fp = open(options.excludefilename) options.toexclude = fp.readlines() fp.close() except IOError: print(_( "Can't read --exclude-file: %s") % options.excludefilename, file=sys.stderr) sys.exit(1) else: options.toexclude = [] # resolve args to module lists expanded = [] for arg in args: if arg == '-': expanded.append(arg) else: expanded.extend(getFilesForName(arg)) args = expanded # slurp through all the files eater = TokenEater(options) for filename in args: if filename == '-': if options.verbose: print(_('Reading standard input')) fp = sys.stdin.buffer closep = 0 else: if options.verbose: print(_('Working on %s') % filename) fp = open(filename, 'rb') closep = 1 try: eater.set_filename(filename) try: tokens = tokenize.tokenize(fp.readline) for _token in tokens: eater(*_token) except tokenize.TokenError as e: print('%s: %s, line %d, column %d' % ( e.args[0], filename, e.args[1][0], e.args[1][1]), file=sys.stderr) finally: if closep: fp.close() # write the output if options.outfile == '-': fp = sys.stdout closep = 0 else: if options.outpath: options.outfile = os.path.join(options.outpath, options.outfile) fp = open(options.outfile, 'w') closep = 1 try: eater.write(fp) finally: if closep: fp.close() if __name__ == '__main__': main() # some more test strings # this one creates a warning _('*** Seen unexpected token "%(token)s"') % {'token': 'test'} _('more' 'than' 'one' 'string')