Skip to main content

Installation

This library will be installed as a dependency by other PNU utilities.

LibPNU(3)

NAME

libpnu — Common utility functions for the PNU project

SYNOPSIS

import libpnu

libpnu.initialize_debugging(String program_name)

libpnu.handle_interrupt_signals(Function handler_function)

libpnu.interrupt_handler_function(Int signal_number, FrameObject current_stack_frame)

String libpnu.get_home_directory()

String libpnu.get_caching_directory(String name)

List libpnu.locate_directory(String directory)

List libpnu.load_strings_from_file(String filename)

DESCRIPTION

The initialize_debugging() function sets up the Python logging module with a syslog style kind of console log using program_name as the program name. By default, the logging level is set at WARNING or more, but can be lowered by calling logging.disable(), for example with the logging.NOTSET parameter to get DEBUG or more logging level.

The handle_interrupt_signals() function calls the specified handler_function to process the SIGINT and SIGPIPE signals, usually to avoid an ugly trace dump to the console in case of interrupt (Control-C pressed or broken pipe). If all you want is printing an "Interrupted" English message and exit your program, then you can use the interrupt_handler_function() as the handler_function.

The get_home_directory() function returns the location of the user's home directory in a string depending on the operating system used (Unix, Windows).

The get_caching_directory() function returns the location of a user writable directory for caching files in a string depending on the operating system used (Unix, Windows). The provided name will be the last directory part of this location.

The locate_directory() function searches the specified directory in a variety of possible other directories, depending on the operating system used (Unix, Windows) and the fact that a package can be user or system installed. It is intended to be used when the directory can't be directly found, and returns a list of paths where the directory searched has been found.

For example, if the argument is "/usr/local/etc/man.d", we'll search for "usr/local/etc/man.d", "local/etc/man.d", "etc/man.d" (more likely) and "man.d" in a list of user's local Python package directories ("$HOME/.local" on Unix, "$APPDATA/python", "$HOMEPATH/appdata/roaming/python", "$USERPROFILE/appdata/roaming/python" on Windows) and system wide Python package base directories (given by sys.base_prefix: "/usr/local" on Unix, "C:/Program Files/Python3x" on Windows).

The load_strings_from_file() function returns a list of strings from the given filename, filtering out comments and empty lines (with '#' being the comment character), and joining continued lines (those ending with a '\' character).

ENVIRONMENT

The following environment variables can be used to identify the user identity and home directory, or find a caching directory.

On Unix: HOME, LNAME, LOGNAME, TMP, TMPDIR, USER and USERNAME.

On Windows: APPDATA, HOME, HOMEPATH, LOCALAPPDATA, TMP and USERPROFILE.

STANDARDS

The libpnu library is not a standard UNIX one.

It tries to follow the PEP 8 style guide for Python code.

PORTABILITY

Tested OK under Windows.

Packaged for FreeBSD as pyXX-pnu-libpnu.

HISTORY

This library was made for the PNU project.

LICENSE

It is available under the 3-clause BSD license.

AUTHORS

Hubert Tournier

Release files for pnu-libpnu 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pnu-libpnu 1.3.0
File Size Uploaded
pnu-libpnu-1.3.0.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pnu-libpnu 1.3.0
File Interpreter ABI Platform
pnu_libpnu-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / pnu-libpnu-1.3.0.tar.gz

Download URL pnu-libpnu-1.3.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
07b2fcb04621fd15322520eed5e3adb09f10255788891ac5fb9ae207e0774509
BLAKE2b-256 checksum
How to use checksums
85f0839f6df3b3f6297181a5469198667723a8ea23285b7e8307138d19422f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / pnu_libpnu-1.3.0-py3-none-any.whl

Download URL pnu_libpnu-1.3.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7e2669f41d5c2c1ae3cff39d33de6e8fab9dd0bc3f777efefc7f719201d70bd
BLAKE2b-256 checksum
How to use checksums
edd80c54cb152baa4cc75757f329d547ae7a36549b425f2be016975612983065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page