Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
Documentation update 2 (#37)
Browse files Browse the repository at this point in the history
* Add CircleCI badge to README.md

* Update gentemplate.py to use libprogress

* Updated libprogress.genfullbar() docstring

* Update README.md to reflect the changes in v3.0
  • Loading branch information
BBaoVanC authored Mar 15, 2020
1 parent c5eb802 commit 13ebb83
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 31 deletions.
104 changes: 77 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# NameGenerator

[![AWESOMENESS](https://img.shields.io/badge/awesomeness-maximum-00a0af.svg)](https://www.youtube.com/channel/UCCiDxF_RZ4fTU_gGJRz-fwQ)
[![Build Status](https://travis-ci.org/BBaoVanC/NameGenerator.svg?branch=master)](https://travis-ci.org/BBaoVanC/NameGenerator)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6621a967fffe47069d53b19129b7be0c)](https://www.codacy.com/manual/BBaoVanC/NameGenerator?utm_source=github.com&utm_medium=referral&utm_content=BBaoVanC/NameGenerator&utm_campaign=Badge_Grade)
[![Travis CI](https://travis-ci.org/BBaoVanC/NameGenerator.svg?branch=master)](https://travis-ci.org/BBaoVanC/NameGenerator)
[![CircleCI](https://circleci.com/gh/BBaoVanC/NameGenerator/tree/master.svg?style=svg)](https://circleci.com/gh/BBaoVanC/NameGenerator/tree/master)

[![license](https://img.shields.io/github/license/BBaoVanC/NameGenerator.svg)](https://github.com/BBaoVanC/NameGenerator/blob/master/LICENSE.txt)
[![Github All Releases](https://img.shields.io/github/downloads/BBaoVanC/NameGenerator/total.svg)](https://github.com/BBaoVanC/NameGenerator)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6621a967fffe47069d53b19129b7be0c)](https://www.codacy.com/manual/BBaoVanC/NameGenerator?utm_source=github.com&utm_medium=referral&utm_content=BBaoVanC/NameGenerator&utm_campaign=Badge_Grade)
[![GitHub watchers](https://img.shields.io/github/watchers/BBaoVanC/NameGenerator.svg?label=Watch)](https://github.com/BBaoVanC/NameGenerator)
[![GitHub stars](https://img.shields.io/github/stars/BBaoVanC/NameGenerator.svg?label=Stars)](https://github.com/BBaoVanC/NameGenerator)

Expand All @@ -17,10 +18,10 @@ Robust name generator that generates awesome names!

* Easy to use
* CLI with simple arguments
* Can be imported as a module
* Only one function when imported as a module
* Can be run directly as a standalone program
* Two types of names to generate
* `libnamegen` can be imported as a module
* `libprogress` can be imported as a module
* CLI can be run with default settings by double-clicking
* Two generation methods to choose from
* Always tested before release
* Uses Python 3
* Supports latest 3 versions of Python
Expand Down Expand Up @@ -60,7 +61,7 @@ Check your Python version. NameGenerator doesn't work on Python 2. It's also onl

### Command-Line Interface

To use the command-line interface, you must have namegen.py and the generators folder. If you will only use specific generators, you don't need to download the other unused ones.
To use the command-line interface, you must have namegen.py and the `libnamegen` folder. If you will only use specific generators, you don't need to download the other unused ones.

Please note that this program is written for Python 3.

Expand All @@ -73,11 +74,11 @@ Use defaults (100 names, debug enabled, classic method, write names to names.txt
``` plaintext
$ python namegen.py
Generating names...
[####################] 100%...done
[####################] 100% [100/100]...done
Preparing list to write to file...done
Opening file...
Writing names...
[####################] 100%...done
[####################] 100% [100/100]...done
Saving file...
Finished!
```
Expand All @@ -101,11 +102,11 @@ Generate 250 names:
``` plaintext
$ python namegen.py amt=250
Generating names...
[####################] 100%...done
[####################] 100% [250/250]...done
Preparing list to write to file...done
Opening file...
Writing names...
[####################] 100%...done
[####################] 100% [250/250]...done
Saving file...
Finished!
```
Expand All @@ -122,11 +123,11 @@ Generate names and place in file usernames.txt:
``` plaintext
$ python namegen.py file=usernames.txt
Generating names...
[####################] 100%...done
[####################] 100% [100/100]...done
Preparing list to write to file...done
Opening file...
Writing names...
[####################] 100%...done
[####################] 100% [100/100]...done
Saving file...
Finished!
```
Expand All @@ -136,11 +137,11 @@ Generate names and place in file users.txt inside the directory "example-names"
``` plaintext
$ python namegen.py file=example-names/users.txt
Generating names...
[####################] 100%...done
[####################] 100% [100/100]...done
Preparing list to write to file...done
Opening file...
Writing names...
[####################] 100%...done
[####################] 100% [100/100]...done
Saving file...
Finished!
```
Expand All @@ -150,11 +151,11 @@ Generate 50 names with debug enabled and place in namelist.txt:
``` plaintext
$ python namegen.py amt=50 debug=True file=namelist.txt
Generating names...
[####################] 100%...done
[####################] 100% [50/50]...done
Preparing list to write to file...done
Opening file...
Writing names...
[####################] 100%...done
[####################] 100% [50/50]...done
Saving file...
Finished!
```
Expand All @@ -166,13 +167,13 @@ The generation method random looks like 'XaYyaknkCoH8'.
You can change the generation method used by using the argument 'method=[method]' and replace [method] with the correct method.

``` plaintext
$ python namegen.py method=classic
$ python namegen.py method=random
Generating names...
[####################] 100%...done
[####################] 100% [100/100]...done
Preparing list to write to file...done
Opening file...
Writing names...
[####################] 100%...done
[####################] 100% [100/100]...done
Saving file...
Finished!
```
Expand All @@ -183,12 +184,12 @@ Double-clicking namegen.py will generate using default options.

### API

To use the API, you only need the generators folder.
To use the API, you only need the `libnamegen` folder.

Generate one classic name without debug:

``` python
from generators import classic
from libnamegen import classic

# this uses the defaults which are one name, debug disabled, and classic generator
print(classic.gen())
Expand All @@ -197,7 +198,7 @@ print(classic.gen())
Generate seven classic names with debug:

``` python
from generators import classic
from libnamegen import classic

print(classic.gen(count=7, debug=True))
# print(classic.gen(7, True)) # also valid
Expand All @@ -206,7 +207,7 @@ print(classic.gen(count=7, debug=True))
Prompt the user for the amount of names, enable debug, and generate classic names:

``` python
from generators import classic
from libnamegen import classic

amt = input("Amount of names to generate >> ")
count = int(amt)
Expand All @@ -219,21 +220,70 @@ for name in names:
Generate one random name without debug:

``` python
from generators import random
from libnamegen import random

print(random.gen())
```

Generate one name using the random method 15 characters long:

``` python
from generators import random
from libnamegen import random

print(random.gen(length=15))
```

---

### Progress Bar API

To use the progress bar API, you only need the libprogress folder.

The following is an example that utilizes a progress bar with default length.

``` python
import libprogress

for i in range(20):
do(something)
print(libprogress.genbar(curprg=i+1, maxprg=20), end="\r")
print(libprogress.genfullbar(prg=20))
```

Final output:

``` plaintext
[####################] 100% [100/100]...done
```

If you don't put `end="\r"`, then each progress bar won't overwrite the last. The output will look like the following:

``` plaintext
[#-------------------] 5% [1/20]
[##------------------] 10% [2/20]
[###-----------------] 15% [3/20]
[####----------------] 20% [4/20]
[#####---------------] 25% [5/20]
[######--------------] 30% [6/20]
[#######-------------] 35% [7/20]
[########------------] 40% [8/20]
[#########-----------] 45% [9/20]
[##########----------] 50% [10/20]
[###########---------] 55% [11/20]
[############--------] 60% [12/20]
[#############-------] 65% [13/20]
[##############------] 70% [14/20]
[###############-----] 75% [15/20]
[################----] 80% [16/20]
[#################---] 85% [17/20]
[##################--] 90% [18/20]
[###################-] 95% [19/20]
[####################] 100% [20/20]
[####################] 100% [20/20]...done
```

---

## License

_NameGenerator_ is licensed under the GPLv3 license. For more information, please refer to [`LICENSE.txt`](https://github.com/BBaoVanC/NameGenerator/blob/master/LICENSE.txt)
8 changes: 5 additions & 3 deletions docs/gentemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
# ^^^ this is only necessary if you use this module, or if you require a
# file as seen below.
import libprogress

# the following two lines of code are not required since they are only for
# requiring a file.
Expand Down Expand Up @@ -45,11 +46,12 @@ def gen(count=1, debug=False): # you may add more arguments after debug
name = "generated_name" # this should generate a name and save it in
# a variable named 'name'
if debug: # if we should output debug information
print("Generated name: ({}/{})".format(n-1, count),
end="\r") # log message for generated names
# print progress bar
print(libprogress.genbar(curprg=n-1, maxprg=count), end="\r")
names.append(name) # add name to list
n = n + 1 # increase counter

if debug: # if we should output debug information
print("Generated name: ({}/{})...done".format(n-1, count)) # log msg
# print last progress bar
print(libprogress.genfullbar(prg=count))
return names # return the names list
2 changes: 1 addition & 1 deletion libprogress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def genfullbar(length=20, prg=100):
prg -- the progress total
The design of the progress bar:
[#####---------------] 25%...done
[####################] 100% [1000/1000]...done
"""
fullbar = "{}...done".format(genbar(length, prg, prg))
return fullbar

0 comments on commit 13ebb83

Please sign in to comment.