Mines DirSearch Python Library, CLI, and Mutt Integration
The Mines DirSearch website allows search of Mines personnel who have their directory information listed in the Banner system. This is a convenient Python interface to that website.
- Author:
Jack Rosenthal
- Requires:
Python 3.4 or greater, Beautiful Soup 4.4.0 or greater, Requests
- License:
MIT
- Contributing:
See CONTRIBUTING.rst
Installing
Clone the repository and install:
$ pip install . --user
Or install from PyPI:
$ pip install csmdirsearch --user
Usage from Python
Use search(query) to search for a user by either (part of) a username, or (part of) a full name. search is a generator that will yield unique Person objects. Typical attributes on this object include name, business_email, major, classification, and department; however, only the name attribute is guaranteed to exist.
Each Person object also has a few properties:
- username:
Based on the business_email (and potentially more information in the future), a “best guess” for the username of the user, otherwise None.
- desc:
An automatic, brief description of the person, for example: Undergraduate Student, Computer Science.
The name of each person is also a special Name type, containing first, last, and nick attributes. You can convert a name to a string using the strfname function, or use str(person.name) for a “reasonable default”:
>>> name = Name("Rosenthal, Jack (NickName)")
>>> name.strfname("{first} {last}")
'Jack Rosenthal'
>>> str(name)
'Jack (NickName) Rosenthal'
There’s also convenience properties to be used in strfname:
- pfirst:
Short for “preferred first”. This will be set to nick if there is a nick name, first otherwise.
- nickp:
Short for “nick, wrapped in parens, if there is one”. This will be set to ' (nick)' if there’s a nick name, '' otherwise.
Example:
>>> name = Name("Rosenthal, Jack (NickName)")
>>> name.strfname("{pfirst} {last}")
'NickName Rosenthal'
>>> name.strfname("{first}{nickp} {last}")
'Jack (NickName) Rosenthal'
Here is an example:
import csmdirsearch
for person in csmdirsearch.search("Jack Rosenthal"):
print(person.name, person.desc)
If you wish to limit your search to just a partial username (no real names), use the search_by_partial generator instead of search.
Finally, if you wish to limit your search to just a partial full name (most efficent), use the search_by_name generator instead of search. This generator also has means to limit a search to a certain classification or department. Read the source code for more details.
Usage from the Command Line
This is wicked simple:
$ dirsearch "Jack Rosenthal" Jack Rosenthal Undergraduate Student Business Email: ...
If you wish to use the search_by_name or search_by_partial functions to limit the scope of the input, use --input=name or --input=partial respectively:
$ dirsearch --input=partial "jrosent" Jack Rosenthal ...
Usage from Mutt
Add to your .muttrc:
set query_command = "dirsearch --format=mutt %s"
Then press Q to compose using a search, or ^T while writing a name or address.
Metadata
Release files for csmdirsearch 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| csmdirsearch-0.1.1.tar.gz | 7.8 kB | Without provenance | Details for csmdirsearch-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| csmdirsearch-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for csmdirsearch-0.1.1-py3-none-any.whl |
Total release size: 15.5 kB
Release files / csmdirsearch-0.1.1.tar.gz
| Download URL | csmdirsearch-0.1.1.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b44539ab0fbd135aade9c99d9c0c4508870cafd4fcec70a01a1c760a5731a760
|
|
BLAKE2b-256 checksum How to use checksums |
4601f7e723192bd75ea56362e6f914f00c8a165c1d0894f79ce9637c6b69cf88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Release files / csmdirsearch-0.1.1-py3-none-any.whl
| Download URL | csmdirsearch-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6277593e68322d54a9c87c57793de971802e49f821e08e45ea38b521392fc1a9
|
|
BLAKE2b-256 checksum How to use checksums |
ae9dfce82dad6900eeae7beb106660e72b434af1563e60f94b292e4f9c230590
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for csmdirsearch 0.1.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.