Skip to main content

A tool to solve daily work.

Project description

workutils

A tool to solve daily work including file encoding conversion, keyword search, and file type analysis.

Installation

You can install, upgrade, or uninstall workutils with these commands:

$ pip install workutils
$ pip install --upgrade workutils
$ pip uninstall workutils

Help

$ workutils -h
usage: workutils [-h] {convert,query,analyze} ...
A tool for daily work

optional arguments:
  -h, --help            show this help message and exit

subcommands:
  {convert,query,analyze}
    convert             Convert the encoding of all files in the specified directory and its subdirectories.
    query               Query the encoding of a specified file.
    analyze             Analyze the file types and keyword occurrences in the specified directory and its subdirectories.

Convert the encoding of files

$ workutils convert -h
usage: workutils convert [-h] [-s SUFFIX] directory target_encoding

positional arguments:
  directory             The directory to process
  target_encoding       The target encoding format, e.g., 'utf-8'

optional arguments:
  -h, --help            show this help message and exit
  -s SUFFIX, --suffix SUFFIX
                        Specify the file extension to process, e.g., '.txt'

Query the encoding of a file

$ workutils query -h
usage: workutils query [-h] file_path

positional arguments:
  file_path             The file path to query

optional arguments:
  -h, --help            show this help message and exit

Analyze file types and keyword occurrences

$ workutils analyze -h
usage: workutils analyze [-h] [-s SUFFIX] [-k KEYWORDS] [-a] [-o OUTPUT] directory

positional arguments:
  directory             The directory to analyze

optional arguments:
  -h, --help            show this help message and exit
  -s SUFFIX, --suffix SUFFIX
                        Specify the file extension to analyze
  -k KEYWORDS, --keywords KEYWORDS
                        Count keywords in all files, such as 'keyword1,keyword2'
  -a, --all-files       Traverse all files, including hidden files
  -o OUTPUT, --output OUTPUT
                        The file path to save the result

Examples

Convert the encoding of files

  1. Convert all .txt files in a directory to utf-8 encoding:
$ workutils convert ./directory utf-8 -s .txt

Query the encoding of a file

  1. Query the encoding of a specific file:
$ workutils query /path/to/file.txt

Analyze file types and keyword occurrences

  1. Analyze the file types in a directory:
$ workutils analyze ../
E:\workutils\a.txt
E:\workutils\LICENSE
E:\workutils\README.md
E:\workutils\workutils\workutils.py
E:\workutils\workutils\__init__.py
========================================
Suffix    Counts
----------------------------------------
.txt      1
          1
.md       1
.py       2
----------------------------------------
Total     5
========================================
  1. Select the folder path and specify the file suffix to analyze:
$ workutils analyze ../ -s py
E:\workutils\workutils\workutils.py
E:\workutils\workutils\__init__.py
========================================
Suffix    Counts
----------------------------------------
.py       2
----------------------------------------
Total     2
========================================
  1. Traverse all files, including hidden files:
$ workutils analyze ../ -a   
E:\workutils\a.txt
E:\workutils\LICENSE
E:\workutils\README.md
E:\workutils\.git\config
...
E:\workutils\.git\refs\remotes\origin\HEAD
E:\workutils\workutils\workutils.py
E:\workutils\workutils\__init__.py
========================================
Suffix    Counts
----------------------------------------
.txt      1
          15
.md       1
.sample   13
.idx      1
.pack     1
.py       2
----------------------------------------
Total     34
========================================
  1. Save the result to a file:
$ workutils analyze ../ -s py -o result.txt
E:\workutils\workutils\workutils.py
E:\workutils\workutils\__init__.py
========================================
Suffix    Counts
----------------------------------------
.py       2
----------------------------------------
Total     2
========================================
The result has been saved to the E:\workutils\workutils\result.txt file.

Content of result.txt:

E:\workutils\workutils\workutils.py
E:\workutils\workutils\__init__.py
  1. Find keywords and count occurrences in all files:
$ workutils analyze ./ -s log -k 'AS0100504GN_2' -o a.txt
E:\workutils\workutils\1111.log
E:\workutils\workutils\a\a.log
E:\workutils\workutils\b\test.log
E:\workutils\workutils\c\c.log
==================================================
Suffix              Counts
--------------------------------------------------
.log                4
--------------------------------------------------
Total               4
==================================================

100%|████████████████████████████████████████████| 4/4 [00:00<00:00,  3.76it/s]
==================================================
Keyword             Matches             File Name
--------------------------------------------------
AS0100504GN_2       32                  1111.log
--------------------------------------------------
==================================================
The result has been saved to the E:\workutils\workutils\a.txt file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

workutils-0.0.8.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

workutils-0.0.8-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file workutils-0.0.8.tar.gz.

File metadata

  • Download URL: workutils-0.0.8.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for workutils-0.0.8.tar.gz
Algorithm Hash digest
SHA256 b3e87b2f2ebf2424b5ee10b9a2625b7abab3a4a1b651b98648f4113b88817ef1
MD5 00787238ab8f80131fd4ee8c9be68157
BLAKE2b-256 994f6524401241713605cf3f72176b90444e8a921f3b035319f32380c0ca2fa3

See more details on using hashes here.

File details

Details for the file workutils-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: workutils-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for workutils-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2a49e02bddae5d1ecb88f45f3ff8d5dcc95db64d8dd4036650b3457818c212e2
MD5 fbc896decdaff18c8a7d1c6d89f82216
BLAKE2b-256 ee982e5570419130163688161eabc0e39c68259500844b8e22bba35a76a572ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page