From f5de9e2587cc7a50da541f95660175a468c55a85 Mon Sep 17 00:00:00 2001 From: Adam Walkiewicz Date: Sun, 16 Nov 2025 12:10:40 +0100 Subject: [PATCH 1/2] Prepare package for the final release * Update docsrtrings * Add version flag to CLI * Unify imports in across test suites --- MANIFEST.in | 5 ---- README.md | 2 +- pyproject.toml | 2 +- src/randname/__init__.py | 35 ++++++++++++++++++++++- src/randname/__main__.py | 29 ++++++++++++++++--- src/randname/config.py | 5 +++- src/randname/core.py | 2 +- tests/test_randnames_es.py | 58 +++++++++++++++++++------------------- tests/test_randnames_pl.py | 58 +++++++++++++++++++------------------- uv.lock | 2 +- 10 files changed, 125 insertions(+), 73 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ecab79c..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include LICENSE -recursive-include randname *.json -recursive-include randname *.py -recursive-include randname/data * -recursive-exclude randname *.ipynb diff --git a/README.md b/README.md index 78cf146..8ce798d 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,4 @@ Detailed documentation of module can by found here: ## License -Randname is licensed under the terms of the [MIT license](license.md) +Randname is licensed under the terms of the [MIT license](LICENSE) diff --git a/pyproject.toml b/pyproject.toml index 05d650e..ae1af42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rname" -version = "1.0.0-beta.1" +version = "1.0.0-beta.2" description = "Get random first/last name" readme = "README.md" authors = [ diff --git a/src/randname/__init__.py b/src/randname/__init__.py index 50f5ea5..1854119 100755 --- a/src/randname/__init__.py +++ b/src/randname/__init__.py @@ -1,5 +1,37 @@ """Randname - A random name generator library. +This package provides functionality for generating random names from various +countries. It includes utilities for generating first names, last names, and +full names, with support for multiple countries and customizable options. + +The package offers a simple API for generating random names that can be used in +testing, data generation, or any application requiring random name generation. + +!! warning + This package uses pseudo-random generators from Python standard library. + This package should not be used for security purposes. + The base package contains limited dataset of names. It is easy to create + a collision. + +Attributes: + __title__ (str): The title of the package. + __name__ (str): The name of the package. + __version__ (str): The current version of the package. + __author__ (str): The author of the package. + __license__ (str): The license under which the package is distributed. + +Examples: + >>> import randname + >>> randname.randfirst() + 'John' + >>> randname.randlast() + 'Smith' + >>> randname.randfull() + 'Jane Doe' + >>> randname.available_countries() + ['PL', 'US', 'ES', ...] + + Modules: config: Configuration for logging. core: Core functionality for generating random names. @@ -17,7 +49,8 @@ show_data, ) -__title__ = "randname" +__title__ = "rname" +__name__ = "randname" __version__ = version(__title__) __author__ = "Adam Walkiewicz" __license__ = "MIT" diff --git a/src/randname/__main__.py b/src/randname/__main__.py index 389559d..447f1d5 100755 --- a/src/randname/__main__.py +++ b/src/randname/__main__.py @@ -1,14 +1,21 @@ import argparse from collections.abc import Sequence +import randname from randname.core import Randname, available_countries, randfirst, randfull, randlast +# Remove `None` from valid choices, because there it is not easy to pass it +# in CLI, and it is not necessary, as the default is None sex_choices = [choice for choice in Randname.VALID_SEX_OPTIONS if choice] -def parse_args(args: Sequence[str] | None = None) -> argparse.Namespace: +def parse_args( + args: Sequence[str] | None = None, +) -> tuple[argparse.Namespace, argparse.ArgumentParser]: parser = argparse.ArgumentParser( - description="Generate a random full name using randname library." + prog="randname", + description="Generate a random name using randname library.", + add_help=False, ) # Mutually exclusive arguments for first name and last name @@ -44,11 +51,25 @@ def parse_args(args: Sequence[str] | None = None) -> argparse.Namespace: help="Specify the year for name generation (default: None).", ) - return parser.parse_args(args) + # Utility arguments + parser.add_argument( + "--version", + action="version", + version=f"%(prog)s {randname.__version__}", + help="Show the version of the randname library and exit.", + ) + parser.add_argument( + "--help", "-h", action="help", help="Show this help message and exit." + ) + + return parser.parse_args(args), parser def main(): - args = parse_args() + args, parser = parse_args() + + if args.help: + parser.print_help() if args.first: name = randfirst(country=args.country, sex=args.sex, year=args.year) diff --git a/src/randname/config.py b/src/randname/config.py index 5407d33..ff20c62 100644 --- a/src/randname/config.py +++ b/src/randname/config.py @@ -1,5 +1,8 @@ """Configuration for logging in the randname library. +This module act as singleton. Once imported it will not be re-imported again. +Thus, `logger` is always the same object. + Attributes: DEFAULT_LOGGING_LEVEL: Default logging level for the application. LOGGING_LEVEL_MAP: Mapping of string logging levels to logging module constants. @@ -46,4 +49,4 @@ def set_logger(level_name: str) -> logging.Logger: return logger -logger = set_logger("debug") +logger = set_logger("error") diff --git a/src/randname/core.py b/src/randname/core.py index 8b66949..ac48d8f 100644 --- a/src/randname/core.py +++ b/src/randname/core.py @@ -12,7 +12,7 @@ Example usage of module: >>> import randname - >>> randname.full_name() + >>> randname.randfull() 'John Doe' Attributes: diff --git a/tests/test_randnames_es.py b/tests/test_randnames_es.py index acada2b..d20412a 100755 --- a/tests/test_randnames_es.py +++ b/tests/test_randnames_es.py @@ -1,8 +1,8 @@ import random import unittest +import randname.core import randname.error -from randname import core class TestRandomNames(unittest.TestCase): @@ -16,130 +16,130 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - core._inst.database = core.Randname.PATH_TO_DATABASE + randname.core._inst.database = randname.core.Randname.PATH_TO_DATABASE def setUp(self): pass def tearDown(self): - core._inst.database = core.Randname.PATH_TO_DATABASE + randname.core._inst.database = randname.core.Randname.PATH_TO_DATABASE def test_last_name_no_arguments(self): - result = core.randlast(country=self.country) + result = randname.core.randlast(country=self.country) self.assertIsInstance(result, str) def test_last_name_sex(self): for sex in self.last_names_sex: - result = core.randlast(country=self.country, sex=sex) + result = randname.core.randlast(country=self.country, sex=sex) self.assertIsInstance(result, str) def test_last_name_year(self): year = random.choice(self.last_names_year_range) - result = core.randlast(country=self.country, year=year) + result = randname.core.randlast(country=self.country, year=year) self.assertIsInstance(result, str) def test_last_name_invalid_sex(self): sex = "D" with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randlast(country=self.country, sex=sex) + randname.core.randlast(country=self.country, sex=sex) def test_last_name_year_not_in_range(self): year = max(self.last_names_year_range) + 1 - result = core.randlast(country=self.country, year=year) + result = randname.core.randlast(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.last_names_year_range) - 1 - result = core.randlast(country=self.country, year=year) + result = randname.core.randlast(country=self.country, year=year) self.assertIsInstance(result, str) def test_last_name_weights(self): weights = False - result = core.randlast(country=self.country, weights=weights) + result = randname.core.randlast(country=self.country, weights=weights) self.assertIsInstance(result, str) def test_first_name_no_arguments(self): - result = core.randfirst(country=self.country) + result = randname.core.randfirst(country=self.country) self.assertIsInstance(result, str) def test_first_name_sex(self): for sex in self.first_names_sex: - result = core.randfirst(country=self.country, sex=sex) + result = randname.core.randfirst(country=self.country, sex=sex) self.assertIsInstance(result, str) def test_first_name_year(self): year = random.choice(self.first_names_year_range) - result = core.randfirst(country=self.country, year=year) + result = randname.core.randfirst(country=self.country, year=year) self.assertIsInstance(result, str) def test_first_name_invalid_sex(self): sex = "D" with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randfirst(country=self.country, sex=sex) + randname.core.randfirst(country=self.country, sex=sex) def test_first_name_year_not_in_range(self): year = max(self.first_names_year_range) + 1 - result = core.randfirst(country=self.country, year=year) + result = randname.core.randfirst(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.first_names_year_range) - 1 - result = core.randfirst(country=self.country, year=year) + result = randname.core.randfirst(country=self.country, year=year) self.assertIsInstance(result, str) def test_first_name_weights(self): weights = False - result = core.randfirst(country=self.country, weights=weights) + result = randname.core.randfirst(country=self.country, weights=weights) self.assertIsInstance(result, str) def test_full_name_no_arguments(self): - result = core.randfull(country=self.country) + result = randname.core.randfull(country=self.country) self.assertIsInstance(result, str) def test_full_name_sex(self): for sex in self.first_names_sex: - result = core.randfull(country=self.country, sex=sex) + result = randname.core.randfull(country=self.country, sex=sex) self.assertIsInstance(result, str) for sex in self.last_names_sex: - result = core.randfull(country=self.country, sex=sex) + result = randname.core.randfull(country=self.country, sex=sex) self.assertIsInstance(result, str) def test_full_name_year(self): year = random.choice(self.first_names_year_range) - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = random.choice(self.last_names_year_range) - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) def test_full_name_invalid_sex(self): sex = "D" with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randfull(country=self.country, sex=sex) + randname.core.randfull(country=self.country, sex=sex) with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randfull(country=self.country, sex=sex) + randname.core.randfull(country=self.country, sex=sex) def test_full_name_year_not_in_range(self): year = max(self.first_names_year_range) + 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.first_names_year_range) - 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.last_names_year_range) + 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.last_names_year_range) - 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) def test_full_name_weights(self): weights = False - result = core.randfull(country=self.country, weights=weights) + result = randname.core.randfull(country=self.country, weights=weights) self.assertIsInstance(result, str) diff --git a/tests/test_randnames_pl.py b/tests/test_randnames_pl.py index 99c93ac..c75f882 100755 --- a/tests/test_randnames_pl.py +++ b/tests/test_randnames_pl.py @@ -1,8 +1,8 @@ import random import unittest +import randname.core import randname.error -from randname import core class TestRandomNames(unittest.TestCase): @@ -16,130 +16,130 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - core._inst.database = core.Randname.PATH_TO_DATABASE + randname.core._inst.database = randname.core.Randname.PATH_TO_DATABASE def setUp(self): pass def tearDown(self): - core._inst.database = core.Randname.PATH_TO_DATABASE + randname.core._inst.database = randname.core.Randname.PATH_TO_DATABASE def test_last_name_no_arguments(self): - result = core.randlast(country=self.country) + result = randname.core.randlast(country=self.country) self.assertIsInstance(result, str) def test_last_name_sex(self): for sex in self.last_names_sex: - result = core.randlast(country=self.country, sex=sex) + result = randname.core.randlast(country=self.country, sex=sex) self.assertIsInstance(result, str) def test_last_name_year(self): year = random.choice(self.last_names_year_range) - result = core.randlast(country=self.country, year=year) + result = randname.core.randlast(country=self.country, year=year) self.assertIsInstance(result, str) def test_last_name_invalid_sex(self): sex = "D" with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randlast(country=self.country, sex=sex) + randname.core.randlast(country=self.country, sex=sex) def test_last_name_year_not_in_range(self): year = max(self.last_names_year_range) + 1 - result = core.randlast(country=self.country, year=year) + result = randname.core.randlast(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.last_names_year_range) - 1 - result = core.randlast(country=self.country, year=year) + result = randname.core.randlast(country=self.country, year=year) self.assertIsInstance(result, str) def test_last_name_weights(self): weights = False - result = core.randlast(country=self.country, weights=weights) + result = randname.core.randlast(country=self.country, weights=weights) self.assertIsInstance(result, str) def test_first_name_no_arguments(self): - result = core.randfirst(country=self.country) + result = randname.core.randfirst(country=self.country) self.assertIsInstance(result, str) def test_first_name_sex(self): for sex in self.first_names_sex: - result = core.randfirst(country=self.country, sex=sex) + result = randname.core.randfirst(country=self.country, sex=sex) self.assertIsInstance(result, str) def test_first_name_year(self): year = random.choice(self.first_names_year_range) - result = core.randfirst(country=self.country, year=year) + result = randname.core.randfirst(country=self.country, year=year) self.assertIsInstance(result, str) def test_first_name_invalid_sex(self): sex = "D" with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randfirst(country=self.country, sex=sex) + randname.core.randfirst(country=self.country, sex=sex) def test_first_name_year_not_in_range(self): year = max(self.first_names_year_range) + 1 - result = core.randfirst(country=self.country, year=year) + result = randname.core.randfirst(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.first_names_year_range) - 1 - result = core.randfirst(country=self.country, year=year) + result = randname.core.randfirst(country=self.country, year=year) self.assertIsInstance(result, str) def test_first_name_weights(self): weights = False - result = core.randfirst(country=self.country, weights=weights) + result = randname.core.randfirst(country=self.country, weights=weights) self.assertIsInstance(result, str) def test_full_name_no_arguments(self): - result = core.randfull(country=self.country) + result = randname.core.randfull(country=self.country) self.assertIsInstance(result, str) def test_full_name_sex(self): for sex in self.first_names_sex: - result = core.randfull(country=self.country, sex=sex) + result = randname.core.randfull(country=self.country, sex=sex) self.assertIsInstance(result, str) for sex in self.last_names_sex: - result = core.randfull(country=self.country, sex=sex) + result = randname.core.randfull(country=self.country, sex=sex) self.assertIsInstance(result, str) def test_full_name_year(self): year = random.choice(self.first_names_year_range) - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = random.choice(self.last_names_year_range) - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) def test_full_name_invalid_sex(self): sex = "D" with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randfull(country=self.country, sex=sex) + randname.core.randfull(country=self.country, sex=sex) with self.assertRaises(randname.error.InvalidSexArgumentError): - core.randfull(country=self.country, sex=sex) + randname.core.randfull(country=self.country, sex=sex) def test_full_name_year_not_in_range(self): year = max(self.first_names_year_range) + 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.first_names_year_range) - 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.last_names_year_range) + 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) year = max(self.last_names_year_range) - 1 - result = core.randfull(country=self.country, year=year) + result = randname.core.randfull(country=self.country, year=year) self.assertIsInstance(result, str) def test_full_name_weights(self): weights = False - result = core.randfull(country=self.country, weights=weights) + result = randname.core.randfull(country=self.country, weights=weights) self.assertIsInstance(result, str) diff --git a/uv.lock b/uv.lock index d8950ae..a189b16 100644 --- a/uv.lock +++ b/uv.lock @@ -715,7 +715,7 @@ wheels = [ [[package]] name = "rname" -version = "1.0.0b1" +version = "1.0.0b2" source = { editable = "." } dependencies = [ { name = "jsonschema" }, From ab4b357a5e7a65fbc941cca3b56933b3eb18b6c3 Mon Sep 17 00:00:00 2001 From: Adam Walkiewicz Date: Sun, 16 Nov 2025 14:52:38 +0100 Subject: [PATCH 2/2] Remove trailing white spaces --- docs/contribution.md | 36 ++++++++++++++--------------- docs/database.md | 30 ++++++++++++------------ docs/environment.md | 16 ++++++------- docs/index.md | 49 +++++++++++++++++++++------------------- mkdocs.yml | 3 +++ src/randname/__init__.py | 4 +--- 6 files changed, 71 insertions(+), 67 deletions(-) diff --git a/docs/contribution.md b/docs/contribution.md index 4d78777..9af71a9 100644 --- a/docs/contribution.md +++ b/docs/contribution.md @@ -1,6 +1,6 @@ # Contributing to randname -In order to make contributing to this project as easy and transparent as possible, +In order to make contributing to this project as easy and transparent as possible, whether it's: - Reporting a bug @@ -11,15 +11,15 @@ whether it's: ## We Develop with Github -We use github to host code, to track issues and feature requests, as well as +We use github to host code, to track issues and feature requests, as well as accept pull requests. ## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html) So All Code Changes Happen Through Pull Requests -Pull requests are the best way to propose changes to the codebase -(we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). +Pull requests are the best way to propose changes to the codebase +(we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests: 1. Fork the repo and create your branch from `master`. @@ -31,21 +31,21 @@ We actively welcome your pull requests: ## Any contributions you make will be under the MIT Software License -In short, when you submit code changes, your submissions are understood to be -under the same [MIT License](http://choosealicense.com/licenses/mit/) that +In short, when you submit code changes, your submissions are understood to be +under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern. ## Report bugs using Github's [issues](https://github.com/briandk/transcriptase-atom/issues) -We use GitHub issues to track public bugs. Report a bug by -[opening a new issue](https://github.com/ajwalkiewicz/randname/issues); +We use GitHub issues to track public bugs. Report a bug by +[opening a new issue](https://github.com/ajwalkiewicz/randname/issues); it's that easy! ## Write bug reports with detail, background, and sample code -[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug -report I wrote, and I think it's not a bad model. Here's -[another example from Craig Hockenberry](http://www.openradar.me/11905408), +[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug +report I wrote, and I think it's not a bad model. Here's +[another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect. **Great Bug Reports** tend to have: @@ -53,13 +53,13 @@ an app developer whom I greatly respect. - A quick summary and/or background - Steps to reproduce - Be specific! - - Give sample code if you can. - [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) - includes sample code that *anyone* with a base pytohn setup can run to + - Give sample code if you can. + [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) + includes sample code that *anyone* with a base pytohn setup can run to reproduce what I was seeing - What you expected would happen - What actually happens -- Notes (possibly including why you think this might be happening, or stuff +- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) People *love* thorough bug reports. I'm not even kidding. @@ -73,15 +73,15 @@ When writing code please follow below PEP's: ## Creating database -Please follow instructions from [database guide](database.md) when creating +Please follow instructions from [database guide](database.md) when creating new database. ## License -By contributing, you agree that your contributions will be licensed under its +By contributing, you agree that your contributions will be licensed under its MIT License. ## References -This document was adapted from the open-source contribution guidelines for +This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md) \ No newline at end of file diff --git a/docs/database.md b/docs/database.md index a4ff4e4..8c4f9bc 100644 --- a/docs/database.md +++ b/docs/database.md @@ -2,20 +2,20 @@ ## Legal warning -Please kep in mind that randname is an open source project and we relay only +Please kep in mind that randname is an open source project and we relay only on legally possessed data. ## How database looks All data files are stored in `data` directory. -`data` directory contains directories for every currently supported country. -Country directories are named accordingly to [Aplha-2 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements). +`data` directory contains directories for every currently supported country. +Country directories are named accordingly to [Aplha-2 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements). It means that directory name is exactly 2 capital letters. -Inside country directory there are 2 separate directories and 1 info.json file. +Inside country directory there are 2 separate directories and 1 info.json file. One for first names and one for las names. - + * `first_names` * `last_names` @@ -35,16 +35,16 @@ Above `info.json` file contain following information: Inside names directories, are actual data files. -Data files are in [JSON](https://en.wikipedia.org/wiki/JSON) format, +Data files are in [JSON](https://en.wikipedia.org/wiki/JSON) format, but without `.json` extension. -Data files has to starts from `year`, `underscore`, and `gender capital letter` +Data files has to starts from `year`, `underscore`, and `gender capital letter` - `M`, `F` or `N`. Example: `1990_M` for male names in 1990. ### What letter to use? -Not all languages have same names grammar. For example english language have -same form of last name regardless the gender. In the other hand some languages +Not all languages have same names grammar. For example english language have +same form of last name regardless the gender. In the other hand some languages like polish have separate last names forms for male and female. Use: @@ -93,19 +93,19 @@ randname/data/ Most of the databases with names are in `.csv` or `.xlsx` formats. -When contributing pleas send also a source file from which you are creating +When contributing pleas send also a source file from which you are creating JSON data. ## Tools -In `/tools` you can find simple python scrip that can help you to create JSON +In `/tools` you can find simple python scrip that can help you to create JSON files from `.xlsx` or `.csv` files. -In order to make it work out of the box, a source file has to have the following +In order to make it work out of the box, a source file has to have the following structure: * contains 2 columns * first column has to be with names -* second column has to be with integer numbers that indicates the number name +* second column has to be with integer numbers that indicates the number name occurrences. ### Example source file @@ -117,7 +117,7 @@ occurrences. | WIŚNIEWSKI | 72658 | | WÓJCIK | 65836 | | KOWALCZYK | 64736 | -|<- snip -> | | +|<- snip -> | | | ŽUK-OLSZEWSKI | 2 | | ŽUKOVSKI | 2 | | ŽUKOVSKIJ | 2 | @@ -132,7 +132,7 @@ python3 convert_to_json.py -t csv -f PL/first_names/Imiona_nadane_wPolsce_w_lata ## Sources -US +US Last names diff --git a/docs/environment.md b/docs/environment.md index 55c360b..4c7d985 100644 --- a/docs/environment.md +++ b/docs/environment.md @@ -1,19 +1,19 @@ # Setting Up the Development Environment -To contribute to the cochar project, it's important to set up a development -environment that matches the project's requirements. This ensures consistency +To contribute to the cochar project, it's important to set up a development +environment that matches the project's requirements. This ensures consistency and reduces the time spent debugging non-existent bugs. ## Prerequisites Before setting up the environment, ensure you have the following installed: -- **Python**: The project is built using Python. Make sure you have Python +- **Python**: The project is built using Python. Make sure you have Python installed on your machine. The project has to be compatible with **python3.12** -- **Make**: We use Make to simplify various tasks such as setup, testing, +- **Make**: We use Make to simplify various tasks such as setup, testing, and building the project. - **Curl**: Required for downloading scripts. -- **Linux** machine: It is not a hard requirement, but all instructions here +- **Linux** machine: It is not a hard requirement, but all instructions here are based on **Ubuntu 22.04**. ## Steps to Set Up the Environment @@ -84,13 +84,13 @@ Before setting up the environment, ensure you have the following installed: make docs_upload ``` -By following these steps, you will have a development environment that is -consistent with the project's requirements. For any issues or further details, +By following these steps, you will have a development environment that is +consistent with the project's requirements. For any issues or further details, refer to the [Contribution Guidelines](contribution.md). ## References -* Python: https://www.python.org/ +* Python: https://www.python.org/ * Project management tool: [UV](https://docs.astral.sh/uv/) * Formatter: [Ruff](https://docs.astral.sh/ruff/) * Testing: [Pytest](https://docs.pytest.org/en/stable/index.html) \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index a96c940..e7f3687 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,20 +10,20 @@ Python module to generate random name. ## Summary -Randname is a python module for generating random name - first and last. +Randname is a python module for generating random name - first and last. It uses official data from appropriate governmental/scientific research centers. -Names are drawn with the consideration of their frequency. Therefor most common +Names are drawn with the consideration of their frequency. Therefor most common name wil be drawn much more often (this feature can be disabled). Currently supported countries: US, PL, ES. -Default database is small, and constrained to 10000 records for each first and +Default database is small, and constrained to 10000 records for each first and last names for every country. Default data size: 60 000 records -With the full database downloaded from project -[github page](https://github.com/ajwalkiewicz/randname/), +With the full database downloaded from project +[github page](https://github.com/ajwalkiewicz/randname/), the amount of names is increased to around 700 000 records. ## Installation @@ -34,8 +34,22 @@ Randname is available in python repository, and can be downloaded with pip. pip3 install rname ``` +Yes, use `rname` to install the package. + ## Usage +!!! warning + Because `randname` package on PyPi was already taken, it was named `rname` + That's why to install in you need to refer to `rname`: + ```bash + pip3 install rname + ``` + But package installs itself as `randname`. And you should import is by + referring to `randname`: + ```python + import randname + ``` + ```Python >>> import randname @@ -57,9 +71,9 @@ pip3 install rname ## Database -Default database included in pypi package is very small. To not make the -package unnecessary too large, every country have one set of data for last -and first names (with distinction for the male, female, neutral name), +Default database included in pypi package is very small. To not make the +package unnecessary too large, every country have one set of data for last +and first names (with distinction for the male, female, neutral name), for the most recent year. Each file contains up to 10000 records. Currently supported countries: @@ -81,7 +95,7 @@ ES: ### Biger database -Full database is bigger and doesn't have the limit of records. If you wan to +Full database is bigger and doesn't have the limit of records. If you wan to use it, download it from project [github page](https://github.com/ajwalkiewicz/randname/). To use other databases specify directory by setting `database_path` variable @@ -97,11 +111,11 @@ More details about database can be found [here](database.md) ## Contribution -If you want to contribute to randname project read +If you want to contribute to randname project read [contribution](contribution.md) for more information. -I am looking especially for help with database creation. More information on -how to help/create appropriate data files with names can be found in +I am looking especially for help with database creation. More information on +how to help/create appropriate data files with names can be found in [database guide](database.md) ## Authors & Contributors @@ -110,17 +124,6 @@ how to help/create appropriate data files with names can be found in **Contributors**: Be first! -## To do - -1. [x] Summary -1. [ ] Tools -1. [ ] Contribution guideline -1. [ ] Unit tests -1. [ ] Instruction for database creation -1. [x] Add equal chances for every name -1. [ ] Support for other countries names -1. [ ] Add 9 more countries - ## License Randname is licensed under the terms of the [MIT license](license.md) diff --git a/mkdocs.yml b/mkdocs.yml index 843fa1b..ccdeca6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,11 +13,14 @@ plugins: group_by_category: true show_submodules: true + markdown_extensions: - pymdownx.highlight: anchor_linenums: true line_spans: __span pygments_lang_class: true + - admonition + - pymdownx.details - pymdownx.inlinehilite - pymdownx.snippets - pymdownx.superfences diff --git a/src/randname/__init__.py b/src/randname/__init__.py index 1854119..c1af3c6 100755 --- a/src/randname/__init__.py +++ b/src/randname/__init__.py @@ -7,7 +7,7 @@ The package offers a simple API for generating random names that can be used in testing, data generation, or any application requiring random name generation. -!! warning +!!! warning This package uses pseudo-random generators from Python standard library. This package should not be used for security purposes. The base package contains limited dataset of names. It is easy to create @@ -15,7 +15,6 @@ Attributes: __title__ (str): The title of the package. - __name__ (str): The name of the package. __version__ (str): The current version of the package. __author__ (str): The author of the package. __license__ (str): The license under which the package is distributed. @@ -50,7 +49,6 @@ ) __title__ = "rname" -__name__ = "randname" __version__ = version(__title__) __author__ = "Adam Walkiewicz" __license__ = "MIT"