Skip to main content

Application that takes a string or file and returns the number of all characters in the string or file occurring only once.

Project description

Single char counter

Installation

Clone this repository to your local machine:

git clone http://git.foxminded.ua/foxstudent103611/task_5.git

Use the package manager pip to install requirements:

pip install -r requirements.txt

Summary

Application that takes a string or file and returns the number of all characters in the string or file occurring only once. The function was tested using pytest. The function is in the single_char_counter_by_ng folder and the tests are in the tests folder. The test_count_single_char folder contains tests and parameterized data. For convenience, some __init__ already have modules imported.

Usage

from single_char_counter_by_ng import (count_single_char, 
                                       count_single_char_in_file)

count_single_char('HelLo') # ---> 5

count_single_char('HelLo', case_insensitive=True) # ---> 3

# file.txt ---> 'HelLo'
count_single_char_in_file('path_to_file/file.txt') # ---> 5

count_single_char_in_file('path_to_file/file.txt', case_insensitive=True) # ---> 3

Also implemented command-line interface(CLI):

python count_single_char.py --string “your string”
python count_single_char.py -s “your string”

or

python count_single_char.py --file "path_to_text_file"
python count_single_char.py -f "path_to_text_file"

There is also a "-i" parameter that can be specified so that the result is case insensitive:

python count_single_char.py -s “your string” -i

If you passed two parameters, the parameter '--file' have higher priority:

python collect_framework.py  --string “your string” --file path_to_text_file

Used

License

MIT

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

single_char_counter_by_ng-1.1.0.tar.gz (37.7 kB view details)

Uploaded Source

File details

Details for the file single_char_counter_by_ng-1.1.0.tar.gz.

File metadata

File hashes

Hashes for single_char_counter_by_ng-1.1.0.tar.gz
Algorithm Hash digest
SHA256 673cf2b79139f1a08432c5c1025082c21fb12a400e63c5a318cd10dfea33e30e
MD5 c6b49f1d8f2b33befd5760c8cc82b20a
BLAKE2b-256 568f88cc592cb04ae950e5c74313bc94341b1f2542cdc8e3f8931eb93de5a4ea

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