Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HubTou authored Mar 6, 2022
1 parent a082666 commit d55217b
Show file tree
Hide file tree
Showing 12 changed files with 916 additions and 2 deletions.
11 changes: 11 additions & 0 deletions License
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright 2022+ Hubert Tournier

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. 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.

3. Neither the name of the copyright holder 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 HOLDER 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.
96 changes: 96 additions & 0 deletions MANPATH.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# MANPATH(1)

## NAME
manpath - display search path for manual pages

## SYNOPSIS
**manpath**
\[-Ldq\]
\[--debug\]
\[--help|-?\]
\[--version\]
\[--\]

## DESCRIPTION
The **manpath** utility determines the user's manual search path from the user's PATH, and local configuration files.
This result is echoed to the standard output.

### OPTIONS
Options | Use
------- | ---
-L|Output manual locales list instead of the manual path.
-d|Print extra debugging information.
-q|Suppresses warning messages.
--debug|Enable debug mode
--help\|-?|Print usage and a short help message and exit
--version|Print version and exit
--|Options processing terminator

## IMPLEMENTATION NOTES
The **manpath** utility constructs the manual path from three sources:
1. From each component of the user's PATH for the first of:
- pathname/man
- pathname/MAN
- If pathname ends with /bin: pathname/../share/man and pathname/../man
2. From default manpath entries:
- /usr/share/man
- /usr/share/openssl/man
- /usr/local/share/man
- /usr/local/man
3. The configuration files listed in the FILES section for MANPATH entries.
The information from these locations is then concatenated together.
If the *-L* flag is set, the **manpath** utility will search the configuration files listed in the FILES section for MANLOCALE entries.

## ENVIRONMENT
The following environment variables affect the execution of **manpath**:

Environment variable | Use
-------------------- | ---
MANLOCALES|If set with the *-L* flag, causes the utility to display a warning and the value, overriding any other configuration found on the system.
MANPATH|If set, causes the utility to display a warning and the value, overriding any other configuration found on the system.
PATH|Influences the manual path as described in the IMPLEMENTATION NOTES.

The *MANPATH_DEBUG* environment variable can also be set to any value to enable debug mode.

The *FLAVOUR* or *MANPATH_FLAVOUR* environment variables can be set to one of the following values, to implement only the corresponding options and behaviours:
* bsd | bsd:freebsd : FreeBSD [manpath(1)](https://www.freebsd.org/cgi/man.cgi?query=manpath)

## FILES
* /etc/man.conf : System configuration file.
* /usr/local/etc/man.d/*.conf : Local configuration files.

## EXIT STATUS
The **manpath** utility exits 0 on success, and >0 if an error occurs.

## SEE ALSO
[apropos(1)](https://www.freebsd.org/cgi/man.cgi?query=apropos),
[man(1)](https://www.freebsd.org/cgi/man.cgi?query=man),
[whatis(1)](https://www.freebsd.org/cgi/man.cgi?query=whatis),
[man.conf(5)](https://www.freebsd.org/cgi/man.cgi?query=man.conf),
[manpath(3)](https://github.com/HubTou/manpath/blob/main/MANPATH.3.md)

## STANDARDS
The **manpath** utility is a standard UNIX command, though not a POSIX one.

This re-implementation tries to follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide for [Python](https://www.python.org/) code.

## PORTABILITY
To be tested under Windows.

## HISTORY
This re-implementation was made for the [PNU project](https://github.com/HubTou/PNU).

## LICENSE
It is available under the [3-clause BSD license](https://opensource.org/licenses/BSD-3-Clause).

## AUTHORS
[Hubert Tournier](https://github.com/HubTou)

The manpath(1) manual page is mainly based on the one written for [FreeBSD](https://www.freebsd.org/) by [Gordon Tetlow](https://github.com/tetlowgm).

## BUGS
This re-implementation corrects 3 (minor) bugs or the original command:
* No warning was displayed when MANPATH was set
* Default manpath entries were supplied when PATH was not set, before "Adding default manpath entries"
* A "Skipping duplicate manpath entry" message was incorrectly displayed with MANPATH directives with empty content in config files

45 changes: 45 additions & 0 deletions MANPATH.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# MANPATH(3)

## NAME
manpath - return the search path for manual pages

## SYNOPSIS
import **manpath**

String *manpath*.**get_manpath**(Integer *debug_level* = 0, Boolean *quiet_mode* = False)

String *manpath*.**get_locales**(Integer *debug_level* = 0, Boolean *quiet_mode* = False)

## DESCRIPTION
The **get_manpath**() function returns a string of colon separated directories containing manual pages.

The **get_locales**() function returns a string of colon separated locales for which there are localized manual pages.

For each of the two functions, if the optional *debug_level* is set to 1, 2 or 3 it will also print increasingly verbose debugging messages to the console.

And if the optional *quiet_mode* argument is set to True it will discard warning messages printed to the console.

## ENVIRONMENT
The following environment variables affect the execution of **manpath**:

Environment variable | Use
-------------------- | ---
MANLOCALES|If set, causes the utility to override any other configuration found on the system.
MANPATH|If set, causes the utility to override any other configuration found on the system.
PATH|Influences the manual path as described in the IMPLEMENTATION NOTES.

## SEE ALSO
[manpath(1)](https://github.com/HubTou/manpath/blob/main/MANPATH.1.md)

## STANDARDS
The **manpath** library tries to follow the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide for [Python](https://www.python.org/) code.

## HISTORY
This library was made for the [PNU project](https://github.com/HubTou/PNU).

## LICENSE
It is available under the [3-clause BSD license](https://opensource.org/licenses/BSD-3-Clause).

## AUTHORS
[Hubert Tournier](https://github.com/HubTou)

64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
NAME=manpath
SECTION=1
SOURCES=src/${NAME}/__init__.py src/${NAME}/main.py

# Default action is to show this help message:
.help:
@echo "Possible targets:"
@echo " check-code Verify PEP 8 compliance (lint)"
@echo " check-security Verify security issues (audit)"
@echo " check-unused Find unused code"
@echo " check-version Find required Python version"
@echo " check-sloc Count Single Lines of Code"
@echo " checks Make all the previous tests"
@echo " format Format code"
@echo " package Build package"
@echo " upload-test Upload the package to TestPyPi"
@echo " upload Upload the package to PyPi"
@echo " distclean Remove all generated files"

check-code: /usr/local/bin/pylint
-pylint ${SOURCES}

lint: check-code

check-security: /usr/local/bin/bandit
-bandit -r ${SOURCES}

audit: check-security

check-unused: /usr/local/bin/vulture
-vulture --sort-by-size ${SOURCES}

check-version: /usr/local/bin/vermin
-vermin ${SOURCES}

check-sloc: /usr/local/bin/pygount
-pygount --format=summary .

checks: check-code check-security check-unused check-version check-sloc

format: /usr/local/bin/black
black ${SOURCES}

love:
@echo "Not war!"

man/${NAME}.${SECTION}.gz: man/${NAME}.${SECTION}
@gzip -k9c man/${NAME}.${SECTION} > man/${NAME}.${SECTION}.gz

man/${NAME}.3.gz: man/${NAME}.3
@gzip -k9c man/${NAME}.3 > man/${NAME}.3.gz

package: man/${NAME}.${SECTION}.gz man/${NAME}.3.gz
python -m build

upload-test:
python -m twine upload --repository testpypi dist/*

upload:
python -m twine upload dist/*

distclean:
rm -rf build dist src/*.egg-info man/${NAME}.${SECTION}.gz man/${NAME}.3.gz

19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# manpath
display search path for manual pages
# Installation
Depending on if you want only this tool, the full set of PNU tools, or PNU plus a selection of additional third-parties tools, use one of these commands:

pip install [pnu-manpath](https://pypi.org/project/pnu-manpath/)
<br>
pip install [PNU](https://pypi.org/project/PNU/)
<br>
pip install [pytnix](https://pypi.org/project/pytnix/)

# MANPATH(1), MANPATH(3)
This repository includes a command-line utility:
* [manpath(1)](https://github.com/HubTou/manpath/blob/main/MANPATH.1.md) - display search path for manual pages

And a Python library:
* [manpath(3)](https://github.com/HubTou/manpath/blob/main/MANPATH.3.md) - return the search path for manual pages


Loading

0 comments on commit d55217b

Please sign in to comment.