Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HubTou committed Feb 28, 2022
1 parent 50fbb59 commit f36c1a8
Show file tree
Hide file tree
Showing 13 changed files with 581 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.
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
NAME=libmanconf
SECTION=3
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/man.conf.5.gz: man/man.conf.5
@gzip -k9c man/man.conf.5 > man/man.conf.5.gz

package: man/${NAME}.${SECTION}.gz man/man.conf.5.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/man.conf.5.gz

53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# libmanconf
library for handling man(1) and manpath(1) configuration files
# Installation
pip install [pnu-libmanconf](https://pypi.org/project/pnu-libmanconf/)

# LIBMANCONF(3)

## NAME
libmanconf — library for handling man(1) and manpath(1) configuration files

## SYNOPSIS
import **libmanconf**

String, String, List *libmanconf*.**read_man_conf_files**(Integer *debug_level* = 0)

## DESCRIPTION
The **read_man_conf_files()** function reads the configuration files located at "/etc/man.conf" and "/usr/local/etc/man.d/\*.conf"
to configure the manual search path, locales and utility set used by man(1) and related utilities.

The function takes an optional argument *debug_level* with an integer value from 0 (default) to 3,
to print increasingly detailed information on standard error output.

It returns a triplet consisting of:
* a string containing colon separated existing MANPATH directories
* a string containing colon separated locales (for example, "fr_FR.UTF-8:ja_JP.eucJP")
* a list containing processors (for example, \["TBL_JA=/usr/local/bin/gtbl", "NROFF_JA=/usr/local/bin/groff -man -dlang=ja_JP.eucJP"\])

## SEE ALSO
[apropos(1)](https://www.freebsd.org/cgi/man.cgi?query=apropos&sektion=1),
[man(1)](https://www.freebsd.org/cgi/man.cgi?query=man&sektion=1),
[man.conf(5)](https://www.freebsd.org/cgi/man.cgi?query=man.conf&sektion=5),
[manpath(1)](https://www.freebsd.org/cgi/man.cgi?query=manpath&sektion=1),
[whatis(1)](https://www.freebsd.org/cgi/man.cgi?query=whatis&sektion=1)

## STANDARDS
The **libmanconf** library is not a standard UNIX one.

It 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 library was made for the [PNU project](https://github.com/HubTou/PNU) to factor code for the man(1) and manpath(1) commands.

## 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 man.conf(5) manual page is largely based on the one written for [FreeBSD](https://www.freebsd.org/) by [Gordon Tetlow](https://github.com/tetlowgm).

71 changes: 71 additions & 0 deletions man/libmanconf.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.Dd February 28, 2022
.Dt LIBMANCONF 3
.Os
.Sh NAME
.Nm libmanconf
.Nd library for handling man(1) and manpath(1) configuration files
.Sh SYNOPSIS
.Em import libmanconf
.Pp
.Ft String, String, List
.Fo libmanconf.read_man_conf_files
.Fa "Integer debug_level = 0"
.Fc
.Sh DESCRIPTION
The
.Fn read_man_conf_files
function reads the configuration files located at
.Pa /etc/man.conf
and
.Pa /usr/local/etc/man.d/*.conf
to configure the manual search path, locales and utility set used by
.Xr man 1
and related utilities.
.Pp
The function takes an optional argument
.Fa debug_level
with an integer value from 0 (default) to 3,
to print increasingly detailed information on standard error output.
.Pp
It returns a triplet consisting of:
.Bl -bullet
.It
a string containing colon separated existing MANPATH directories
.It
a string containing colon separated locales (for example, "fr_FR.UTF-8:ja_JP.eucJP")
.It
a list containing processors (for example, ["TBL_JA=/usr/local/bin/gtbl", "NROFF_JA=/usr/local/bin/groff -man -dlang=ja_JP.eucJP"])
.El
.Sh SEE ALSO
.Xr apropos 1 ,
.Xr man 1 ,
.Xr man.conf 5 ,
.Xr manpath 1 ,
.Xr whatis 1
.Sh STANDARDS
The
.Lb
library is not a standard UNIX one.
.Pp
It tries to follow the PEP 8 style guide for Python code.
.Sh PORTABILITY
To be tested under Windows.
.Sh HISTORY
This library was made for the
.Lk https://github.com/HubTou/PNU [PNU project]
to factor code for the
.Xr man 1
and
.Xr manpath 1
commands.
.Sh LICENSE
It is available under the 3-clause BSD license.
.Sh AUTHORS
.An Hubert Tournier
.Pp
The
.Xr man.conf 5
manual page is largely based on the one written for
.Fx
by
.An Gordon Tetlow
141 changes: 141 additions & 0 deletions man/man.conf.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
.\"-
.\" Copyright (c) 2010 Gordon Tetlow
.\" All rights reserved.
.\"
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
.\"
.\" $FreeBSD$
.\"
.Dd February 28, 2022
.Dt MAN.CONF 5
.Os
.Sh NAME
.Nm man.conf
.Nd
.Xr man 1
and
.Xr manpath 1
configuration files
.Sh DESCRIPTION
The
.Nm
file is used to configure the manual search path, locales, and utility set for
.Xr man 1
and its related utilities.
During initialization,
.Xr man 1
reads the configuration files located at
.Pa /usr/local/etc/man.d/*.conf
and
.Pa /etc/man.conf .
.Pp
The files contained in
.Pa /usr/local/etc/man.d/*.conf
are intended to be used by packaging systems for extending the manual set to support additional paths and locales.
.Pa /etc/man.conf
is intended to be used by the local administrator to set additional policy.
.Pp
Currently supported configuration variables include:
.Bl -tag -width 12n -offset indent
.It MANCONFIG
Overrides the default location to import additional manual configuration files.
Defaults to
.Pa /usr/local/etc/man.d/*.conf .
.It MANPATH
Adds the specified directory to the manual search path.
.It MANLOCALE
Indicates support is available for the given locale.
.El
.Pp
For pages in a given language, overriding the default toolset for
display is supported via the following definitions:
.Pp
.Bl -tag -width 12n -offset indent -compact
.It EQN Ns _ Ns Va LANG
.It NROFF Ns _ Ns Va LANG
.It PIC Ns _ Ns Va LANG
.It TBL Ns _ Ns Va LANG
.It TROFF Ns _ Ns Va LANG
.It REFER Ns _ Ns Va LANG
.It VGRIND Ns _ Ns Va LANG
.El
.Pp
See the
.Sx EXAMPLES
section for how to use these variables.
.Sh IMPLEMENTATION NOTES
The parser used for this utility is very basic and only supports comment
characters (#) at the beginning of a line, blank lines, multiple spaces
or tabs as argument separators.
.Sh FILES
.Bl -tag -width "Pa /usr/local/etc/man.d/*.conf" -compact
.It Pa /etc/man.conf
System configuration file.
.It Pa /usr/local/etc/man.d/*.conf
Local configuration files.
.El
.Sh EXAMPLES
A perl port that needs to install additional manual pages outside of the
default location could install a file in
.Pa /usr/local/etc/man.d/perl.conf
with the following contents:
.Bd -literal -offset indent
# Add perl man pages to search path
MANPATH /usr/local/lib/perl5/5.8.9/man
MANPATH /usr/local/lib/perl5/5.8.9/perl/man
.Ed
.Pp
A Japanese localization port could install a custom toolset and include a
file in
.Pa /usr/local/etc/man.d/ja-man-doc.conf
with the following contents:
.Bd -literal -offset indent
# Setup Japanese toolset
MANLOCALE ja_JP.eucJP
EQN_JA /usr/local/bin/geqn
PIC_JA /usr/local/bin/gpic
TBL_JA /usr/local/bin/gtbl
NROFF_JA /usr/local/bin/groff -man -dlang=ja_JP.eucJP
TROFF_JA /usr/local/bin/groff -man -dlang=ja_JP.euc.jp
.Ed
.Pp
If the system administrator decides to override the
.Va LOCALBASE
.Xr make 1
variable causing all
.Xr ports 7
to be installed into
.Pa /opt
instead of
.Pa /usr/local ,
specifying the following in
.Pa /etc/man.conf
will accommodate this change:
.Bd -literal -offset indent
# Look for additional configuration files
MANCONFIG /opt/etc/man.d/*.conf
.Ed
.Sh SEE ALSO
.Xr apropos 1 ,
.Xr man 1 ,
.Xr manpath 1 ,
.Xr whatis 1
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
Loading

0 comments on commit f36c1a8

Please sign in to comment.