mirror of https://github.com/lukechilds/node.git
Browse Source
Its only dependant was closure-linter but that was removed in commit
f9dd34d
("tools: replace closure-linter with eslint"). Remove it.
Fixes: https://github.com/nodejs/node/issues/3217
PR-URL: https://github.com/nodejs/node/pull/3220
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v4.x
Ben Noordhuis
9 years ago
committed by
James M Snell
21 changed files with 0 additions and 4154 deletions
@ -1 +0,0 @@ |
|||
google-gflags@googlegroups.com |
@ -1,28 +0,0 @@ |
|||
Copyright (c) 2006, Google Inc. |
|||
All rights reserved. |
|||
|
|||
Redistribution and use in source and binary forms, with or without |
|||
modification, are permitted provided that the following conditions are |
|||
met: |
|||
|
|||
* Redistributions of source code must retain the above copyright |
|||
notice, this list of conditions and the following disclaimer. |
|||
* Redistributions in binary form must reproduce the above |
|||
copyright notice, this list of conditions and the following disclaimer |
|||
in the documentation and/or other materials provided with the |
|||
distribution. |
|||
* Neither the name of Google Inc. nor the names of its |
|||
contributors may be used to endorse or promote products derived from |
|||
this software without specific prior written permission. |
|||
|
|||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -1,62 +0,0 @@ |
|||
Wed Jan 18 13:57:39 2012 Google Inc. <google-gflags@googlegroups.com> |
|||
|
|||
* python-gflags: version 2.0 |
|||
* No changes from version 1.8. |
|||
|
|||
Wed Jan 18 11:54:03 2012 Google Inc. <google-gflags@googlegroups.com> |
|||
|
|||
* python-gflags: version 1.8 |
|||
* Don't raise DuplicateFlag when re-importing a module (mmcdonald) |
|||
* Changed the 'official' python-gflags email in setup.py/etc |
|||
* Changed copyright text to reflect Google's relinquished ownership |
|||
|
|||
Tue Dec 20 17:10:41 2011 Google Inc. <opensource@google.com> |
|||
|
|||
* python-gflags: version 1.7 |
|||
* Prepare gflags for python 3.x, keeping 2.4 compatibility (twouters) |
|||
* If output is a tty, use terminal's width to wrap help-text (wiesmann) |
|||
* PORTING: Fix ImportError for non-Unix platforms (kdeus) |
|||
* PORTING: Run correctly when termios isn't available (shines) |
|||
* Add unicode support to flags (csilvers) |
|||
|
|||
Fri Jul 29 12:24:08 2011 Google Inc. <opensource@google.com> |
|||
|
|||
* python-gflags: version 1.6 |
|||
* Document FlagValues.UseGnuGetOpt (garymm) |
|||
* replace fchmod with chmod to work on python 2.4 (mshields) |
|||
* Fix bug in flag decl reporting for dup flags (craigcitro) |
|||
* Add multi_float, and tests for multi_float/int (simonf) |
|||
* Make flagfiles expand in place, to follow docs (dmlynch) |
|||
* Raise exception if --flagfile can't be read (tlim) |
|||
|
|||
Wed Jan 26 13:50:46 2011 Google Inc. <opensource@google.com> |
|||
|
|||
* python-gflags: version 1.5.1 |
|||
* Fix manifest and setup.py to include new files |
|||
|
|||
Mon Jan 24 16:58:10 2011 Google Inc. <opensource@google.com> |
|||
|
|||
* python-gflags: version 1.5 |
|||
* Add support for flag validators (olexiy) |
|||
* Better reporting on UnrecognizedFlagError (sorenj) |
|||
* Cache ArgumentParser, to save space (tmarek) |
|||
|
|||
Wed Oct 13 17:40:12 2010 Google Inc. <opensource@google.com> |
|||
|
|||
* python-gflags: version 1.4 |
|||
* Unregister per-command flags after running the command (dnr) |
|||
* Allow key-flags to work with special flags (salcianu) |
|||
* Allow printing flags of a specific module (mikecurtis) |
|||
* BUGFIX: Fix an error message for float flags (olexiy) |
|||
* BUGFIX: Can now import while defining flags (salcianu) |
|||
* BUGFIX: Fix flagfile parsing in python (chronos) |
|||
* DOC: Better explain the format of --helpxml output (salcianu) |
|||
* DOC: Better error message on parse failure (tstromberg) |
|||
* Better test coverage under python 2.2 (mshields) |
|||
* Added a Makefile for building the packages. |
|||
|
|||
Mon Jan 4 18:46:29 2010 Tim 'mithro' Ansell <mithro@mithis.com> |
|||
|
|||
* python-gflags: version 1.3 |
|||
* Fork from the C++ package (google-gflags 1.3) |
|||
* Add debian packaging |
@ -1,19 +0,0 @@ |
|||
include AUTHORS |
|||
include COPYING |
|||
include ChangeLog |
|||
include MANIFEST.in |
|||
include Makefile |
|||
include NEWS |
|||
include README |
|||
include debian/README |
|||
include debian/changelog |
|||
include debian/compat |
|||
include debian/control |
|||
include debian/copyright |
|||
include debian/docs |
|||
include debian/rules |
|||
include gflags.py |
|||
include gflags2man.py |
|||
include gflags_validators.py |
|||
include setup.py |
|||
recursive-include tests *.py |
@ -1,69 +0,0 @@ |
|||
|
|||
prep: |
|||
@echo |
|||
# Install needed packages |
|||
sudo apt-get install subversion fakeroot python-setuptools python-subversion |
|||
# |
|||
@echo |
|||
# Check that the person has .pypirc |
|||
@if [ ! -e ~/.pypirc ]; then \
|
|||
echo "Please create a ~/.pypirc with the following contents:"; \
|
|||
echo "[server-login]"; \
|
|||
echo "username:google_opensource"; \
|
|||
echo "password:<see valentine>"; \
|
|||
fi |
|||
# |
|||
@echo |
|||
# FIXME(tansell): Check that the person has .dputrc for PPA |
|||
|
|||
clean: |
|||
# Clean up any build files. |
|||
python setup.py clean --all |
|||
# |
|||
# Clean up the debian stuff |
|||
fakeroot ./debian/rules clean |
|||
# |
|||
# Clean up everything else |
|||
rm MANIFEST || true |
|||
rm -rf build-* |
|||
# |
|||
# Clean up the egg files |
|||
rm -rf *egg* |
|||
# |
|||
# Remove dist |
|||
rm -rf dist |
|||
|
|||
dist: |
|||
# Generate the tarball based on MANIFEST.in |
|||
python setup.py sdist |
|||
# |
|||
# Build the debian packages |
|||
fakeroot ./debian/rules binary |
|||
mv ../python-gflags*.deb ./dist/ |
|||
# |
|||
# Build the python Egg |
|||
python setup.py bdist_egg |
|||
# |
|||
@echo |
|||
@echo "Files to upload:" |
|||
@echo "--------------------------" |
|||
@ls -l ./dist/ |
|||
|
|||
push: |
|||
# Send the updates to svn |
|||
# Upload the source package to code.google.com |
|||
- /home/build/opensource/tools/googlecode_upload.py \
|
|||
-p python-gflags ./dist/* |
|||
# |
|||
# Upload the package to PyPi |
|||
- python setup.py sdist upload |
|||
- python setup.py bdist_egg upload |
|||
# |
|||
# Upload the package to the ppa |
|||
# FIXME(tansell): dput should run here |
|||
|
|||
check: |
|||
# Run all the tests. |
|||
for test in tests/*.py; do PYTHONPATH=. python $$test || exit 1; done |
|||
|
|||
.PHONY: prep dist clean push check |
@ -1,77 +0,0 @@ |
|||
== 18 January 2012 == |
|||
|
|||
[Prependum:] I just realized I should have named the new version 2.0, |
|||
to reflect the new ownership and status as a community run project. |
|||
Not too late, I guess. I've just released python-gflags 2.0, which is |
|||
identical to python-gflags 1.8 except for the version number. |
|||
|
|||
I've just released python-gflags 1.8. This fixes a bug, allowing |
|||
modules defining flags to be re-imported without raising duplicate |
|||
flag errors. |
|||
|
|||
Administrative note: In the coming weeks, I'll be stepping down as |
|||
maintainer for the python-gflags project, and as part of that Google |
|||
is relinquishing ownership of the project; it will now be entirely |
|||
community run. The remaining |
|||
[http://python-gflags.googlecode.com/svn/tags/python-gflags-1.8/ChangeLog changes] |
|||
in this release reflect that shift. |
|||
|
|||
|
|||
=== 20 December 2011 === |
|||
|
|||
I've just released python-gflags 1.7. The major change here is |
|||
improved unicode support, in both flag default values and |
|||
help-strings. We've also made big steps toward making gflags work |
|||
with python 3.x (while keeping 2.4 compatibility), and improving |
|||
--help output in the common case where output is a tty. |
|||
|
|||
For a full list of changes since last release, see the |
|||
[http://python-gflags.googlecode.com/svn/tags/python-gflags-1.7/ChangeLog ChangeLog]. |
|||
|
|||
=== 29 July 2011 === |
|||
|
|||
I've just released python-gflags 1.6. This release has only minor |
|||
changes, including support for multi_float flags. The full list of |
|||
changes is in the |
|||
[http://python-gflags.googlecode.com/svn/tags/python-gflags-1.6/ChangeLog ChangeLog]. |
|||
|
|||
The major change with this release is procedural: I've changed the |
|||
internal tools used to integrate Google-supplied patches for gflags |
|||
into the opensource release. These new tools should result in more |
|||
frequent updates with better change descriptions. They will also |
|||
result in future `ChangeLog` entries being much more verbose (for |
|||
better or for worse). |
|||
|
|||
=== 26 January 2011 === |
|||
|
|||
I've just released python-gflags 1.5.1. I had improperly packaged |
|||
python-gflags 1.5, so it probably doesn't work. All users who have |
|||
updated to python-gflags 1.5 are encouraged to update again to 1.5.1. |
|||
|
|||
=== 24 January 2011 === |
|||
|
|||
I've just released python-gflags 1.5. This release adds support for |
|||
flag verifiers: small functions you can associate with flags, that are |
|||
called whenever the flag value is set or modified, and can verify that |
|||
the new value is legal. It also has other, minor changes, described |
|||
in the |
|||
[http://python-gflags.googlecode.com/svn/tags/python-gflags-1.5/ChangeLog ChangeLog]. |
|||
|
|||
=== 11 October 2010 === |
|||
|
|||
I've just released python-gflags 1.4. This release has only minor |
|||
changes from 1.3, including support for printing flags of a specific |
|||
module, allowing key-flags to work with special flags, somewhat better |
|||
error messaging, and |
|||
[http://python-gflags.googlecode.com/svn/tags/python-gflags-1.4/ChangeLog so forth]. |
|||
If 1.3 is working well for you, there's no particular reason to upgrade. |
|||
|
|||
=== 4 January 2010 === |
|||
|
|||
I just released python-gflags 1.3. This is the first python-gflags |
|||
release; it is version 1.3 because this code is forked from the 1.3 |
|||
release of google-gflags. |
|||
|
|||
I don't have a tarball or .deb file up quite yet, so for now you will |
|||
have to get the source files by browsing under the 'source' |
|||
tag. Downloadable files will be available soon. |
@ -1,10 +0,0 @@ |
|||
Metadata-Version: 1.0 |
|||
Name: python-gflags |
|||
Version: 2.0 |
|||
Summary: Google Commandline Flags Module |
|||
Home-page: http://code.google.com/p/python-gflags |
|||
Author: Google Inc. and others |
|||
Author-email: google-gflags@googlegroups.com |
|||
License: BSD |
|||
Description: UNKNOWN |
|||
Platform: UNKNOWN |
@ -1,23 +0,0 @@ |
|||
This repository contains a python implementation of the Google commandline |
|||
flags module. |
|||
|
|||
GFlags defines a *distributed* command line system, replacing systems like |
|||
getopt(), optparse and manual argument processing. Rather than an application |
|||
having to define all flags in or near main(), each python module defines flags |
|||
that are useful to it. When one python module imports another, it gains |
|||
access to the other's flags. |
|||
|
|||
It includes the ability to define flag types (boolean, float, interger, list), |
|||
autogeneration of help (in both human and machine readable format) and reading |
|||
arguments from a file. It also includes the ability to automatically generate |
|||
man pages from the help flags. |
|||
|
|||
Documentation for implementation is at the top of gflags.py file. |
|||
|
|||
To install the python module, run |
|||
python ./setup.py install |
|||
|
|||
When you install this library, you also get a helper application, |
|||
gflags2man.py, installed into /usr/local/bin. You can run gflags2man.py to |
|||
create an instant man page, with all the commandline flags and their docs, for |
|||
any C++ or python program you've written using the gflags library. |
@ -1,7 +0,0 @@ |
|||
The list of files here isn't complete. For a step-by-step guide on |
|||
how to set this package up correctly, check out |
|||
http://www.debian.org/doc/maint-guide/ |
|||
|
|||
Most of the files that are in this directory are boilerplate. |
|||
However, you may need to change the list of binary-arch dependencies |
|||
in 'rules'. |
@ -1,54 +0,0 @@ |
|||
python-gflags (2.0-1) unstable; urgency=low |
|||
|
|||
* New upstream release. |
|||
|
|||
-- Google Inc. <google-gflags@googlegroups.com> Wed, 18 Jan 2012 13:57:39 -0800 |
|||
|
|||
python-gflags (1.8-1) unstable; urgency=low |
|||
|
|||
* New upstream release. |
|||
|
|||
-- Google Inc. <google-gflags@googlegroups.com> Wed, 18 Jan 2012 11:54:03 -0800 |
|||
|
|||
python-gflags (1.7-1) unstable; urgency=low |
|||
|
|||
* New upstream release. |
|||
|
|||
-- Google Inc. <opensource@google.com> Tue, 20 Dec 2011 17:10:41 -0800 |
|||
|
|||
python-gflags (1.6-1) unstable; urgency=low |
|||
|
|||
* New upstream release. |
|||
|
|||
-- Google Inc. <opensource@google.com> Fri, 29 Jul 2011 12:24:08 -0700 |
|||
|
|||
python-gflags (1.5.1-1) unstable; urgency=low |
|||
|
|||
* New upstream release (fixes manifest and setup.py files) |
|||
|
|||
-- Google Inc. <opensource@google.com> Wed, 26 Jan 2011 13:50:46 -0800 |
|||
|
|||
python-gflags (1.5-1) unstable; urgency=low |
|||
|
|||
* New upstream release. |
|||
|
|||
-- Google Inc. <opensource@google.com> Mon, 24 Jan 2011 16:58:10 -0800 |
|||
|
|||
python-gflags (1.4-1) unstable; urgency=low |
|||
|
|||
* New upstream release. |
|||
|
|||
-- Google Inc. <opensource@google.com> Wed, 13 Oct 2010 17:40:12 -0700 |
|||
|
|||
python-gflags (1.3-2) unstable; urgency=low |
|||
|
|||
* Fixed man-page generation. |
|||
|
|||
-- Tim 'mithro' Ansell <mithro@mithis.com> Mon, 07 Jan 2010 13:46:10 +1100 |
|||
|
|||
python-gflags (1.3-1) unstable; urgency=low |
|||
|
|||
* Initial release. |
|||
* Packaging based on gflags 1.3 |
|||
|
|||
-- Tim 'mithro' Ansell <mithro@mithis.com> Mon, 04 Jan 2010 18:46:10 -0800 |
@ -1 +0,0 @@ |
|||
5 |
@ -1,25 +0,0 @@ |
|||
Source: python-gflags |
|||
Section: python |
|||
XS-Python-Version: all |
|||
Priority: optional |
|||
Maintainer: Craig Silverstein <google-gflags@googlegroups.com> |
|||
Build-Depends-Indep: python-central (>= 0.5.6), python-setuptools (>= 0.6b3-1), python-all |
|||
Build-Depends: debhelper (>= 5.0.38) |
|||
Standards-Version: 3.7.2 |
|||
|
|||
Package: python-gflags |
|||
Architecture: all |
|||
Depends: ${python:Depends} |
|||
XB-Python-Version: ${python:Versions} |
|||
Description: A Python implementation of the Google commandline flags module |
|||
. |
|||
GFlags defines a *distributed* command line system, replacing systems like |
|||
getopt(), optparse and manual argument processing. Rather than an application |
|||
having to define all flags in or near main(), each Python module defines flags |
|||
that are useful to it. When one Python module imports another, it gains |
|||
access to the other's flags. |
|||
. |
|||
It includes the ability to define flag types (boolean, float, interger, list), |
|||
autogeneration of help (in both human and machine readable format) and reading |
|||
arguments from a file. It also includes the ability to automatically generate |
|||
man pages from the help flags. |
@ -1,41 +0,0 @@ |
|||
This package was debianized by Craig Silverstein <google-gflags@googlegroups.com> on |
|||
Wed, 18 Jan 2012 13:57:39 -0800. |
|||
|
|||
It was downloaded from http://code.google.com/p/python-gflags/downloads/list |
|||
|
|||
Upstream Author: Google Inc. and others <google-gflags@googlegroups.com> |
|||
Copyright: Google Inc. and others <google-gflags@googlegroups.com> |
|||
|
|||
License: |
|||
|
|||
Copyright (c) 2006, Google Inc. |
|||
All rights reserved. |
|||
|
|||
Redistribution and use in source and binary forms, with or without |
|||
modification, are permitted provided that the following conditions are |
|||
met: |
|||
|
|||
* Redistributions of source code must retain the above copyright |
|||
notice, this list of conditions and the following disclaimer. |
|||
* Redistributions in binary form must reproduce the above |
|||
copyright notice, this list of conditions and the following disclaimer |
|||
in the documentation and/or other materials provided with the |
|||
distribution. |
|||
* Neither the name of Google Inc. nor the names of its |
|||
contributors may be used to endorse or promote products derived from |
|||
this software without specific prior written permission. |
|||
|
|||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|||
|
|||
The Debian packaging is (C) 2011, Tim 'mithro' Ansell <mithro@mithis.com> and |
|||
is licensed under the above. |
@ -1,2 +0,0 @@ |
|||
AUTHORS |
|||
README |
@ -1,62 +0,0 @@ |
|||
#!/usr/bin/make -f |
|||
# -*- makefile -*- |
|||
# Sample debian/rules that uses debhelper. |
|||
# GNU copyright 1997 to 1999 by Joey Hess. |
|||
|
|||
# Uncomment this to turn on verbose mode. |
|||
#export DH_VERBOSE=1 |
|||
|
|||
PYTHON := /usr/bin/python |
|||
#PYVER := $(shell $(PYTHON) -c 'import sys; print sys.version[:3]') |
|||
PYVERS = $(shell pyversions -vr) |
|||
|
|||
build: $(PYVERS:%=build-python%) |
|||
touch $@ |
|||
|
|||
build-python%: |
|||
dh_testdir |
|||
python$* setup.py build |
|||
touch $@ |
|||
|
|||
clean: |
|||
dh_testdir |
|||
dh_testroot |
|||
rm -f build-python* |
|||
rm -rf build |
|||
-find . -name '*.py[co]' | xargs rm -f |
|||
dh_clean |
|||
|
|||
install: build $(PYVERS:%=install-python%) |
|||
|
|||
install-python%: |
|||
dh_testdir |
|||
dh_testroot |
|||
dh_clean -k |
|||
dh_installdirs |
|||
python$* setup.py install --root=$(CURDIR)/debian/python-gflags --prefix=/usr |
|||
# Scripts should not have a .py on the end of them |
|||
mv $(CURDIR)/debian/python-gflags/usr/bin/gflags2man.py $(CURDIR)/debian/python-gflags/usr/bin/gflags2man |
|||
# Generate a man file for gflags2man |
|||
mkdir -p $(CURDIR)/debian/python-gflags/usr/share/man/man1 |
|||
PYTHONPATH=$(CURDIR)/debian/.. python$* gflags2man.py --dest_dir $(CURDIR)/debian/python-gflags/usr/share/man/man1 $(CURDIR)/debian/python-gflags/usr/bin/gflags2man |
|||
|
|||
# Build architecture-independent files here. |
|||
binary-indep: build install |
|||
dh_testdir |
|||
dh_testroot |
|||
dh_installchangelogs -k ChangeLog |
|||
dh_installdocs |
|||
dh_pycentral |
|||
dh_compress -X.py |
|||
dh_fixperms |
|||
dh_installdeb |
|||
dh_gencontrol |
|||
dh_md5sums |
|||
dh_builddeb |
|||
|
|||
# Build architecture-dependent files here. |
|||
binary-arch: build install |
|||
# We have nothing to do by default. |
|||
|
|||
binary: binary-indep binary-arch |
|||
.PHONY: build clean binary-indep binary-arch binary install configure |
File diff suppressed because it is too large
@ -1,544 +0,0 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2006, Google Inc. |
|||
# All rights reserved. |
|||
# |
|||
# Redistribution and use in source and binary forms, with or without |
|||
# modification, are permitted provided that the following conditions are |
|||
# met: |
|||
# |
|||
# * Redistributions of source code must retain the above copyright |
|||
# notice, this list of conditions and the following disclaimer. |
|||
# * Redistributions in binary form must reproduce the above |
|||
# copyright notice, this list of conditions and the following disclaimer |
|||
# in the documentation and/or other materials provided with the |
|||
# distribution. |
|||
# * Neither the name of Google Inc. nor the names of its |
|||
# contributors may be used to endorse or promote products derived from |
|||
# this software without specific prior written permission. |
|||
# |
|||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|||
|
|||
|
|||
"""gflags2man runs a Google flags base program and generates a man page. |
|||
|
|||
Run the program, parse the output, and then format that into a man |
|||
page. |
|||
|
|||
Usage: |
|||
gflags2man <program> [program] ... |
|||
""" |
|||
|
|||
# TODO(csilvers): work with windows paths (\) as well as unix (/) |
|||
|
|||
# This may seem a bit of an end run, but it: doesn't bloat flags, can |
|||
# support python/java/C++, supports older executables, and can be |
|||
# extended to other document formats. |
|||
# Inspired by help2man. |
|||
|
|||
|
|||
|
|||
import os |
|||
import re |
|||
import sys |
|||
import stat |
|||
import time |
|||
|
|||
import gflags |
|||
|
|||
_VERSION = '0.1' |
|||
|
|||
|
|||
def _GetDefaultDestDir(): |
|||
home = os.environ.get('HOME', '') |
|||
homeman = os.path.join(home, 'man', 'man1') |
|||
if home and os.path.exists(homeman): |
|||
return homeman |
|||
else: |
|||
return os.environ.get('TMPDIR', '/tmp') |
|||
|
|||
FLAGS = gflags.FLAGS |
|||
gflags.DEFINE_string('dest_dir', _GetDefaultDestDir(), |
|||
'Directory to write resulting manpage to.' |
|||
' Specify \'-\' for stdout') |
|||
gflags.DEFINE_string('help_flag', '--help', |
|||
'Option to pass to target program in to get help') |
|||
gflags.DEFINE_integer('v', 0, 'verbosity level to use for output') |
|||
|
|||
|
|||
_MIN_VALID_USAGE_MSG = 9 # if fewer lines than this, help is suspect |
|||
|
|||
|
|||
class Logging: |
|||
"""A super-simple logging class""" |
|||
def error(self, msg): print >>sys.stderr, "ERROR: ", msg |
|||
def warn(self, msg): print >>sys.stderr, "WARNING: ", msg |
|||
def info(self, msg): print msg |
|||
def debug(self, msg): self.vlog(1, msg) |
|||
def vlog(self, level, msg): |
|||
if FLAGS.v >= level: print msg |
|||
logging = Logging() |
|||
class App: |
|||
def usage(self, shorthelp=0): |
|||
print >>sys.stderr, __doc__ |
|||
print >>sys.stderr, "flags:" |
|||
print >>sys.stderr, str(FLAGS) |
|||
def run(self): |
|||
main(sys.argv) |
|||
app = App() |
|||
|
|||
|
|||
def GetRealPath(filename): |
|||
"""Given an executable filename, find in the PATH or find absolute path. |
|||
Args: |
|||
filename An executable filename (string) |
|||
Returns: |
|||
Absolute version of filename. |
|||
None if filename could not be found locally, absolutely, or in PATH |
|||
""" |
|||
if os.path.isabs(filename): # already absolute |
|||
return filename |
|||
|
|||
if filename.startswith('./') or filename.startswith('../'): # relative |
|||
return os.path.abspath(filename) |
|||
|
|||
path = os.getenv('PATH', '') |
|||
for directory in path.split(':'): |
|||
tryname = os.path.join(directory, filename) |
|||
if os.path.exists(tryname): |
|||
if not os.path.isabs(directory): # relative directory |
|||
return os.path.abspath(tryname) |
|||
return tryname |
|||
if os.path.exists(filename): |
|||
return os.path.abspath(filename) |
|||
return None # could not determine |
|||
|
|||
class Flag(object): |
|||
"""The information about a single flag.""" |
|||
|
|||
def __init__(self, flag_desc, help): |
|||
"""Create the flag object. |
|||
Args: |
|||
flag_desc The command line forms this could take. (string) |
|||
help The help text (string) |
|||
""" |
|||
self.desc = flag_desc # the command line forms |
|||
self.help = help # the help text |
|||
self.default = '' # default value |
|||
self.tips = '' # parsing/syntax tips |
|||
|
|||
|
|||
class ProgramInfo(object): |
|||
"""All the information gleaned from running a program with --help.""" |
|||
|
|||
# Match a module block start, for python scripts --help |
|||
# "goopy.logging:" |
|||
module_py_re = re.compile(r'(\S.+):$') |
|||
# match the start of a flag listing |
|||
# " -v,--verbosity: Logging verbosity" |
|||
flag_py_re = re.compile(r'\s+(-\S+):\s+(.*)$') |
|||
# " (default: '0')" |
|||
flag_default_py_re = re.compile(r'\s+\(default:\s+\'(.*)\'\)$') |
|||
# " (an integer)" |
|||
flag_tips_py_re = re.compile(r'\s+\((.*)\)$') |
|||
|
|||
# Match a module block start, for c++ programs --help |
|||
# "google/base/commandlineflags": |
|||
module_c_re = re.compile(r'\s+Flags from (\S.+):$') |
|||
# match the start of a flag listing |
|||
# " -v,--verbosity: Logging verbosity" |
|||
flag_c_re = re.compile(r'\s+(-\S+)\s+(.*)$') |
|||
|
|||
# Match a module block start, for java programs --help |
|||
# "com.google.common.flags" |
|||
module_java_re = re.compile(r'\s+Flags for (\S.+):$') |
|||
# match the start of a flag listing |
|||
# " -v,--verbosity: Logging verbosity" |
|||
flag_java_re = re.compile(r'\s+(-\S+)\s+(.*)$') |
|||
|
|||
def __init__(self, executable): |
|||
"""Create object with executable. |
|||
Args: |
|||
executable Program to execute (string) |
|||
""" |
|||
self.long_name = executable |
|||
self.name = os.path.basename(executable) # name |
|||
# Get name without extension (PAR files) |
|||
(self.short_name, self.ext) = os.path.splitext(self.name) |
|||
self.executable = GetRealPath(executable) # name of the program |
|||
self.output = [] # output from the program. List of lines. |
|||
self.desc = [] # top level description. List of lines |
|||
self.modules = {} # { section_name(string), [ flags ] } |
|||
self.module_list = [] # list of module names in their original order |
|||
self.date = time.localtime(time.time()) # default date info |
|||
|
|||
def Run(self): |
|||
"""Run it and collect output. |
|||
|
|||
Returns: |
|||
1 (true) If everything went well. |
|||
0 (false) If there were problems. |
|||
""" |
|||
if not self.executable: |
|||
logging.error('Could not locate "%s"' % self.long_name) |
|||
return 0 |
|||
|
|||
finfo = os.stat(self.executable) |
|||
self.date = time.localtime(finfo[stat.ST_MTIME]) |
|||
|
|||
logging.info('Running: %s %s </dev/null 2>&1' |
|||
% (self.executable, FLAGS.help_flag)) |
|||
# --help output is often routed to stderr, so we combine with stdout. |
|||
# Re-direct stdin to /dev/null to encourage programs that |
|||
# don't understand --help to exit. |
|||
(child_stdin, child_stdout_and_stderr) = os.popen4( |
|||
[self.executable, FLAGS.help_flag]) |
|||
child_stdin.close() # '</dev/null' |
|||
self.output = child_stdout_and_stderr.readlines() |
|||
child_stdout_and_stderr.close() |
|||
if len(self.output) < _MIN_VALID_USAGE_MSG: |
|||
logging.error('Error: "%s %s" returned only %d lines: %s' |
|||
% (self.name, FLAGS.help_flag, |
|||
len(self.output), self.output)) |
|||
return 0 |
|||
return 1 |
|||
|
|||
def Parse(self): |
|||
"""Parse program output.""" |
|||
(start_line, lang) = self.ParseDesc() |
|||
if start_line < 0: |
|||
return |
|||
if 'python' == lang: |
|||
self.ParsePythonFlags(start_line) |
|||
elif 'c' == lang: |
|||
self.ParseCFlags(start_line) |
|||
elif 'java' == lang: |
|||
self.ParseJavaFlags(start_line) |
|||
|
|||
def ParseDesc(self, start_line=0): |
|||
"""Parse the initial description. |
|||
|
|||
This could be Python or C++. |
|||
|
|||
Returns: |
|||
(start_line, lang_type) |
|||
start_line Line to start parsing flags on (int) |
|||
lang_type Either 'python' or 'c' |
|||
(-1, '') if the flags start could not be found |
|||
""" |
|||
exec_mod_start = self.executable + ':' |
|||
|
|||
after_blank = 0 |
|||
start_line = 0 # ignore the passed-in arg for now (?) |
|||
for start_line in range(start_line, len(self.output)): # collect top description |
|||
line = self.output[start_line].rstrip() |
|||
# Python flags start with 'flags:\n' |
|||
if ('flags:' == line |
|||
and len(self.output) > start_line+1 |
|||
and '' == self.output[start_line+1].rstrip()): |
|||
start_line += 2 |
|||
logging.debug('Flags start (python): %s' % line) |
|||
return (start_line, 'python') |
|||
# SWIG flags just have the module name followed by colon. |
|||
if exec_mod_start == line: |
|||
logging.debug('Flags start (swig): %s' % line) |
|||
return (start_line, 'python') |
|||
# C++ flags begin after a blank line and with a constant string |
|||
if after_blank and line.startswith(' Flags from '): |
|||
logging.debug('Flags start (c): %s' % line) |
|||
return (start_line, 'c') |
|||
# java flags begin with a constant string |
|||
if line == 'where flags are': |
|||
logging.debug('Flags start (java): %s' % line) |
|||
start_line += 2 # skip "Standard flags:" |
|||
return (start_line, 'java') |
|||
|
|||
logging.debug('Desc: %s' % line) |
|||
self.desc.append(line) |
|||
after_blank = (line == '') |
|||
else: |
|||
logging.warn('Never found the start of the flags section for "%s"!' |
|||
% self.long_name) |
|||
return (-1, '') |
|||
|
|||
def ParsePythonFlags(self, start_line=0): |
|||
"""Parse python/swig style flags.""" |
|||
modname = None # name of current module |
|||
modlist = [] |
|||
flag = None |
|||
for line_num in range(start_line, len(self.output)): # collect flags |
|||
line = self.output[line_num].rstrip() |
|||
if not line: # blank |
|||
continue |
|||
|
|||
mobj = self.module_py_re.match(line) |
|||
if mobj: # start of a new module |
|||
modname = mobj.group(1) |
|||
logging.debug('Module: %s' % line) |
|||
if flag: |
|||
modlist.append(flag) |
|||
self.module_list.append(modname) |
|||
self.modules.setdefault(modname, []) |
|||
modlist = self.modules[modname] |
|||
flag = None |
|||
continue |
|||
|
|||
mobj = self.flag_py_re.match(line) |
|||
if mobj: # start of a new flag |
|||
if flag: |
|||
modlist.append(flag) |
|||
logging.debug('Flag: %s' % line) |
|||
flag = Flag(mobj.group(1), mobj.group(2)) |
|||
continue |
|||
|
|||
if not flag: # continuation of a flag |
|||
logging.error('Flag info, but no current flag "%s"' % line) |
|||
mobj = self.flag_default_py_re.match(line) |
|||
if mobj: # (default: '...') |
|||
flag.default = mobj.group(1) |
|||
logging.debug('Fdef: %s' % line) |
|||
continue |
|||
mobj = self.flag_tips_py_re.match(line) |
|||
if mobj: # (tips) |
|||
flag.tips = mobj.group(1) |
|||
logging.debug('Ftip: %s' % line) |
|||
continue |
|||
if flag and flag.help: |
|||
flag.help += line # multiflags tack on an extra line |
|||
else: |
|||
logging.info('Extra: %s' % line) |
|||
if flag: |
|||
modlist.append(flag) |
|||
|
|||
def ParseCFlags(self, start_line=0): |
|||
"""Parse C style flags.""" |
|||
modname = None # name of current module |
|||
modlist = [] |
|||
flag = None |
|||
for line_num in range(start_line, len(self.output)): # collect flags |
|||
line = self.output[line_num].rstrip() |
|||
if not line: # blank lines terminate flags |
|||
if flag: # save last flag |
|||
modlist.append(flag) |
|||
flag = None |
|||
continue |
|||
|
|||
mobj = self.module_c_re.match(line) |
|||
if mobj: # start of a new module |
|||
modname = mobj.group(1) |
|||
logging.debug('Module: %s' % line) |
|||
if flag: |
|||
modlist.append(flag) |
|||
self.module_list.append(modname) |
|||
self.modules.setdefault(modname, []) |
|||
modlist = self.modules[modname] |
|||
flag = None |
|||
continue |
|||
|
|||
mobj = self.flag_c_re.match(line) |
|||
if mobj: # start of a new flag |
|||
if flag: # save last flag |
|||
modlist.append(flag) |
|||
logging.debug('Flag: %s' % line) |
|||
flag = Flag(mobj.group(1), mobj.group(2)) |
|||
continue |
|||
|
|||
# append to flag help. type and default are part of the main text |
|||
if flag: |
|||
flag.help += ' ' + line.strip() |
|||
else: |
|||
logging.info('Extra: %s' % line) |
|||
if flag: |
|||
modlist.append(flag) |
|||
|
|||
def ParseJavaFlags(self, start_line=0): |
|||
"""Parse Java style flags (com.google.common.flags).""" |
|||
# The java flags prints starts with a "Standard flags" "module" |
|||
# that doesn't follow the standard module syntax. |
|||
modname = 'Standard flags' # name of current module |
|||
self.module_list.append(modname) |
|||
self.modules.setdefault(modname, []) |
|||
modlist = self.modules[modname] |
|||
flag = None |
|||
|
|||
for line_num in range(start_line, len(self.output)): # collect flags |
|||
line = self.output[line_num].rstrip() |
|||
logging.vlog(2, 'Line: "%s"' % line) |
|||
if not line: # blank lines terminate module |
|||
if flag: # save last flag |
|||
modlist.append(flag) |
|||
flag = None |
|||
continue |
|||
|
|||
mobj = self.module_java_re.match(line) |
|||
if mobj: # start of a new module |
|||
modname = mobj.group(1) |
|||
logging.debug('Module: %s' % line) |
|||
if flag: |
|||
modlist.append(flag) |
|||
self.module_list.append(modname) |
|||
self.modules.setdefault(modname, []) |
|||
modlist = self.modules[modname] |
|||
flag = None |
|||
continue |
|||
|
|||
mobj = self.flag_java_re.match(line) |
|||
if mobj: # start of a new flag |
|||
if flag: # save last flag |
|||
modlist.append(flag) |
|||
logging.debug('Flag: %s' % line) |
|||
flag = Flag(mobj.group(1), mobj.group(2)) |
|||
continue |
|||
|
|||
# append to flag help. type and default are part of the main text |
|||
if flag: |
|||
flag.help += ' ' + line.strip() |
|||
else: |
|||
logging.info('Extra: %s' % line) |
|||
if flag: |
|||
modlist.append(flag) |
|||
|
|||
def Filter(self): |
|||
"""Filter parsed data to create derived fields.""" |
|||
if not self.desc: |
|||
self.short_desc = '' |
|||
return |
|||
|
|||
for i in range(len(self.desc)): # replace full path with name |
|||
if self.desc[i].find(self.executable) >= 0: |
|||
self.desc[i] = self.desc[i].replace(self.executable, self.name) |
|||
|
|||
self.short_desc = self.desc[0] |
|||
word_list = self.short_desc.split(' ') |
|||
all_names = [ self.name, self.short_name, ] |
|||
# Since the short_desc is always listed right after the name, |
|||
# trim it from the short_desc |
|||
while word_list and (word_list[0] in all_names |
|||
or word_list[0].lower() in all_names): |
|||
del word_list[0] |
|||
self.short_desc = '' # signal need to reconstruct |
|||
if not self.short_desc and word_list: |
|||
self.short_desc = ' '.join(word_list) |
|||
|
|||
|
|||
class GenerateDoc(object): |
|||
"""Base class to output flags information.""" |
|||
|
|||
def __init__(self, proginfo, directory='.'): |
|||
"""Create base object. |
|||
Args: |
|||
proginfo A ProgramInfo object |
|||
directory Directory to write output into |
|||
""" |
|||
self.info = proginfo |
|||
self.dirname = directory |
|||
|
|||
def Output(self): |
|||
"""Output all sections of the page.""" |
|||
self.Open() |
|||
self.Header() |
|||
self.Body() |
|||
self.Footer() |
|||
|
|||
def Open(self): raise NotImplementedError # define in subclass |
|||
def Header(self): raise NotImplementedError # define in subclass |
|||
def Body(self): raise NotImplementedError # define in subclass |
|||
def Footer(self): raise NotImplementedError # define in subclass |
|||
|
|||
|
|||
class GenerateMan(GenerateDoc): |
|||
"""Output a man page.""" |
|||
|
|||
def __init__(self, proginfo, directory='.'): |
|||
"""Create base object. |
|||
Args: |
|||
proginfo A ProgramInfo object |
|||
directory Directory to write output into |
|||
""" |
|||
GenerateDoc.__init__(self, proginfo, directory) |
|||
|
|||
def Open(self): |
|||
if self.dirname == '-': |
|||
logging.info('Writing to stdout') |
|||
self.fp = sys.stdout |
|||
else: |
|||
self.file_path = '%s.1' % os.path.join(self.dirname, self.info.name) |
|||
logging.info('Writing: %s' % self.file_path) |
|||
self.fp = open(self.file_path, 'w') |
|||
|
|||
def Header(self): |
|||
self.fp.write( |
|||
'.\\" DO NOT MODIFY THIS FILE! It was generated by gflags2man %s\n' |
|||
% _VERSION) |
|||
self.fp.write( |
|||
'.TH %s "1" "%s" "%s" "User Commands"\n' |
|||
% (self.info.name, time.strftime('%x', self.info.date), self.info.name)) |
|||
self.fp.write( |
|||
'.SH NAME\n%s \\- %s\n' % (self.info.name, self.info.short_desc)) |
|||
self.fp.write( |
|||
'.SH SYNOPSIS\n.B %s\n[\\fIFLAGS\\fR]...\n' % self.info.name) |
|||
|
|||
def Body(self): |
|||
self.fp.write( |
|||
'.SH DESCRIPTION\n.\\" Add any additional description here\n.PP\n') |
|||
for ln in self.info.desc: |
|||
self.fp.write('%s\n' % ln) |
|||
self.fp.write( |
|||
'.SH OPTIONS\n') |
|||
# This shows flags in the original order |
|||
for modname in self.info.module_list: |
|||
if modname.find(self.info.executable) >= 0: |
|||
mod = modname.replace(self.info.executable, self.info.name) |
|||
else: |
|||
mod = modname |
|||
self.fp.write('\n.P\n.I %s\n' % mod) |
|||
for flag in self.info.modules[modname]: |
|||
help_string = flag.help |
|||
if flag.default or flag.tips: |
|||
help_string += '\n.br\n' |
|||
if flag.default: |
|||
help_string += ' (default: \'%s\')' % flag.default |
|||
if flag.tips: |
|||
help_string += ' (%s)' % flag.tips |
|||
self.fp.write( |
|||
'.TP\n%s\n%s\n' % (flag.desc, help_string)) |
|||
|
|||
def Footer(self): |
|||
self.fp.write( |
|||
'.SH COPYRIGHT\nCopyright \(co %s Google.\n' |
|||
% time.strftime('%Y', self.info.date)) |
|||
self.fp.write('Gflags2man created this page from "%s %s" output.\n' |
|||
% (self.info.name, FLAGS.help_flag)) |
|||
self.fp.write('\nGflags2man was written by Dan Christian. ' |
|||
' Note that the date on this' |
|||
' page is the modification date of %s.\n' % self.info.name) |
|||
|
|||
|
|||
def main(argv): |
|||
argv = FLAGS(argv) # handles help as well |
|||
if len(argv) <= 1: |
|||
app.usage(shorthelp=1) |
|||
return 1 |
|||
|
|||
for arg in argv[1:]: |
|||
prog = ProgramInfo(arg) |
|||
if not prog.Run(): |
|||
continue |
|||
prog.Parse() |
|||
prog.Filter() |
|||
doc = GenerateMan(prog, FLAGS.dest_dir) |
|||
doc.Output() |
|||
return 0 |
|||
|
|||
if __name__ == '__main__': |
|||
app.run() |
@ -1,187 +0,0 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2010, Google Inc. |
|||
# All rights reserved. |
|||
# |
|||
# Redistribution and use in source and binary forms, with or without |
|||
# modification, are permitted provided that the following conditions are |
|||
# met: |
|||
# |
|||
# * Redistributions of source code must retain the above copyright |
|||
# notice, this list of conditions and the following disclaimer. |
|||
# * Redistributions in binary form must reproduce the above |
|||
# copyright notice, this list of conditions and the following disclaimer |
|||
# in the documentation and/or other materials provided with the |
|||
# distribution. |
|||
# * Neither the name of Google Inc. nor the names of its |
|||
# contributors may be used to endorse or promote products derived from |
|||
# this software without specific prior written permission. |
|||
# |
|||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|||
|
|||
"""Module to enforce different constraints on flags. |
|||
|
|||
A validator represents an invariant, enforced over a one or more flags. |
|||
See 'FLAGS VALIDATORS' in gflags.py's docstring for a usage manual. |
|||
""" |
|||
|
|||
__author__ = 'olexiy@google.com (Olexiy Oryeshko)' |
|||
|
|||
|
|||
class Error(Exception): |
|||
"""Thrown If validator constraint is not satisfied.""" |
|||
|
|||
|
|||
class Validator(object): |
|||
"""Base class for flags validators. |
|||
|
|||
Users should NOT overload these classes, and use gflags.Register... |
|||
methods instead. |
|||
""" |
|||
|
|||
# Used to assign each validator an unique insertion_index |
|||
validators_count = 0 |
|||
|
|||
def __init__(self, checker, message): |
|||
"""Constructor to create all validators. |
|||
|
|||
Args: |
|||
checker: function to verify the constraint. |
|||
Input of this method varies, see SimpleValidator and |
|||
DictionaryValidator for a detailed description. |
|||
message: string, error message to be shown to the user |
|||
""" |
|||
self.checker = checker |
|||
self.message = message |
|||
Validator.validators_count += 1 |
|||
# Used to assert validators in the order they were registered (CL/18694236) |
|||
self.insertion_index = Validator.validators_count |
|||
|
|||
def Verify(self, flag_values): |
|||
"""Verify that constraint is satisfied. |
|||
|
|||
flags library calls this method to verify Validator's constraint. |
|||
Args: |
|||
flag_values: gflags.FlagValues, containing all flags |
|||
Raises: |
|||
Error: if constraint is not satisfied. |
|||
""" |
|||
param = self._GetInputToCheckerFunction(flag_values) |
|||
if not self.checker(param): |
|||
raise Error(self.message) |
|||
|
|||
def GetFlagsNames(self): |
|||
"""Return the names of the flags checked by this validator. |
|||
|
|||
Returns: |
|||
[string], names of the flags |
|||
""" |
|||
raise NotImplementedError('This method should be overloaded') |
|||
|
|||
def PrintFlagsWithValues(self, flag_values): |
|||
raise NotImplementedError('This method should be overloaded') |
|||
|
|||
def _GetInputToCheckerFunction(self, flag_values): |
|||
"""Given flag values, construct the input to be given to checker. |
|||
|
|||
Args: |
|||
flag_values: gflags.FlagValues, containing all flags. |
|||
Returns: |
|||
Return type depends on the specific validator. |
|||
""" |
|||
raise NotImplementedError('This method should be overloaded') |
|||
|
|||
|
|||
class SimpleValidator(Validator): |
|||
"""Validator behind RegisterValidator() method. |
|||
|
|||
Validates that a single flag passes its checker function. The checker function |
|||
takes the flag value and returns True (if value looks fine) or, if flag value |
|||
is not valid, either returns False or raises an Exception.""" |
|||
def __init__(self, flag_name, checker, message): |
|||
"""Constructor. |
|||
|
|||
Args: |
|||
flag_name: string, name of the flag. |
|||
checker: function to verify the validator. |
|||
input - value of the corresponding flag (string, boolean, etc). |
|||
output - Boolean. Must return True if validator constraint is satisfied. |
|||
If constraint is not satisfied, it should either return False or |
|||
raise Error. |
|||
message: string, error message to be shown to the user if validator's |
|||
condition is not satisfied |
|||
""" |
|||
super(SimpleValidator, self).__init__(checker, message) |
|||
self.flag_name = flag_name |
|||
|
|||
def GetFlagsNames(self): |
|||
return [self.flag_name] |
|||
|
|||
def PrintFlagsWithValues(self, flag_values): |
|||
return 'flag --%s=%s' % (self.flag_name, flag_values[self.flag_name].value) |
|||
|
|||
def _GetInputToCheckerFunction(self, flag_values): |
|||
"""Given flag values, construct the input to be given to checker. |
|||
|
|||
Args: |
|||
flag_values: gflags.FlagValues |
|||
Returns: |
|||
value of the corresponding flag. |
|||
""" |
|||
return flag_values[self.flag_name].value |
|||
|
|||
|
|||
class DictionaryValidator(Validator): |
|||
"""Validator behind RegisterDictionaryValidator method. |
|||
|
|||
Validates that flag values pass their common checker function. The checker |
|||
function takes flag values and returns True (if values look fine) or, |
|||
if values are not valid, either returns False or raises an Exception. |
|||
""" |
|||
def __init__(self, flag_names, checker, message): |
|||
"""Constructor. |
|||
|
|||
Args: |
|||
flag_names: [string], containing names of the flags used by checker. |
|||
checker: function to verify the validator. |
|||
input - dictionary, with keys() being flag_names, and value for each |
|||
key being the value of the corresponding flag (string, boolean, etc). |
|||
output - Boolean. Must return True if validator constraint is satisfied. |
|||
If constraint is not satisfied, it should either return False or |
|||
raise Error. |
|||
message: string, error message to be shown to the user if validator's |
|||
condition is not satisfied |
|||
""" |
|||
super(DictionaryValidator, self).__init__(checker, message) |
|||
self.flag_names = flag_names |
|||
|
|||
def _GetInputToCheckerFunction(self, flag_values): |
|||
"""Given flag values, construct the input to be given to checker. |
|||
|
|||
Args: |
|||
flag_values: gflags.FlagValues |
|||
Returns: |
|||
dictionary, with keys() being self.lag_names, and value for each key |
|||
being the value of the corresponding flag (string, boolean, etc). |
|||
""" |
|||
return dict([key, flag_values[key].value] for key in self.flag_names) |
|||
|
|||
def PrintFlagsWithValues(self, flag_values): |
|||
prefix = 'flags ' |
|||
flags_with_values = [] |
|||
for key in self.flag_names: |
|||
flags_with_values.append('%s=%s' % (key, flag_values[key].value)) |
|||
return prefix + ', '.join(flags_with_values) |
|||
|
|||
def GetFlagsNames(self): |
|||
return self.flag_names |
@ -1,4 +0,0 @@ |
|||
[egg_info] |
|||
tag_build = |
|||
tag_date = 0 |
|||
tag_svn_revision = 0 |
@ -1,44 +0,0 @@ |
|||
#!/usr/bin/env python |
|||
|
|||
# Copyright (c) 2007, Google Inc. |
|||
# All rights reserved. |
|||
# |
|||
# Redistribution and use in source and binary forms, with or without |
|||
# modification, are permitted provided that the following conditions are |
|||
# met: |
|||
# |
|||
# * Redistributions of source code must retain the above copyright |
|||
# notice, this list of conditions and the following disclaimer. |
|||
# * Redistributions in binary form must reproduce the above |
|||
# copyright notice, this list of conditions and the following disclaimer |
|||
# in the documentation and/or other materials provided with the |
|||
# distribution. |
|||
# * Neither the name of Google Inc. nor the names of its |
|||
# contributors may be used to endorse or promote products derived from |
|||
# this software without specific prior written permission. |
|||
# |
|||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|||
|
|||
from setuptools import setup |
|||
|
|||
setup(name='python-gflags', |
|||
version='2.0', |
|||
description='Google Commandline Flags Module', |
|||
license='BSD', |
|||
author='Google Inc. and others', |
|||
author_email='google-gflags@googlegroups.com', |
|||
url='http://code.google.com/p/python-gflags', |
|||
py_modules=["gflags", "gflags_validators"], |
|||
data_files=[("bin", ["gflags2man.py"])], |
|||
include_package_data=True, |
|||
) |
Loading…
Reference in new issue