Skip to main content

pyUTok - Unique TOKens in python

Inspired by a tool I can not find anymore on the internet: utok 1.5. I use it to clean up path settings in large shell script configuration setups.

utok has the following options:

usage:

utok [-h] [–delimiter DELIMITER] [–delete-list DELETE_LIST] [–version] tokens [tokens …]

positional arguments:

tokens

options:
-h, --help

show this help message and exit

--delimiter DELIMITER, -s DELIMITER

Allows one to change the delimiter. If you use csh you might want to set your path with something like: set path = (utok -s /usr/local/bin $path) (default: :)

--delete-list DELETE_LIST, -d DELETE_LIST

Allows one to remove tokens from a list, to remove /usr/sbin and . from a path in Bourne Shell one might use: PATH=`utok $PATH -d .:/usr/sbin` (default: None)

--version, -V

show program’s version number and exit

Documentation

Documentation can be found here

Availability

The latest version should be available at my GitLab repository, the package is avaliable at pypi via pip install pyutok.

Description

utok, Unique TOKens, takes a list of arguments with delimiters and reject all duplicate entries. Here is a example using MANPATH:

$ echo $MANPATH
/usr/man:/usr/local/man
$ MANPATH=`utok /home/local/man /usr/local/man $MANPATH /usr/openwin/man`
$ export MANPATH
$ echo $MANPATH
/home/local/man:/usr/local/man:/usr/man:/usr/openwin/man

Even though /usr/local/man was included a second time it is only in the MANPATH once, though it is now before the /usr/man entry instead of after it.

This version adds the -d option to remove tokens. To remove . from the PATH one would do the following:

$ echo $PATH
/usr/local/bin:.:/usr/bin:/usr/sbin
$ PATH=`utok -d .: $PATH`
$ echo PATH
/usr/local/bin:/usr/bin:/usr/sbin
$ export PATH

Requested Features

  • Have a way to to push an element further back in the path. A work around of this would be be something like:

    $ utok `utok a:b:c:d -d b` b

    which returns: a:c:d:b

  • Have a way to include multiple -s options.

Feedback

Comments or bug reports/fixes go to Berthold Höllmann <berhoel@gmail.com>.

Copyright © 2020 Berthold Höllmann <berhoel@gmail.com>

Original C version: Copyright © 1998 Sven Heinicke <sven@zen.org>

Metadata

Release files for pyutok 1.2.1

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

Source distribution (sdist)

Source distribution for pyutok 1.2.1
File Size Uploaded Provenance Actions
pyutok-1.2.1.tar.gz 4.9 kB Without provenance Details for pyutok-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyutok 1.2.1
File Interpreter ABI Platform Actions
pyutok-1.2.1-py3-none-any.whl Python 3 none any Details for pyutok-1.2.1-py3-none-any.whl

Total release size: 9.5 kB

Release files / pyutok-1.2.1.tar.gz

Download URL pyutok-1.2.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fb22d1eebdb8a8db3f00ea3c146155dfb984280da0579b08f561c76993acde58
BLAKE2b-256 checksum
How to use checksums
174ea338d38fbb4e7a3a499f2df99506deeee730aacdcad3bce123e6f90ae508
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Linux/6.9.7-1-default

Release files / pyutok-1.2.1-py3-none-any.whl

Download URL pyutok-1.2.1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12090b7c1fbd90c7f49cbe32835cf321ce69111254aca8c319ccc56c69cdf912
BLAKE2b-256 checksum
How to use checksums
70f2c4d0dd265a0a63d5e84ff5f74660b041e0a0713f5a3584d40cd07aec90e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Linux/6.9.7-1-default

Security for pyutok 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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