-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
15 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
from random import choice, randint | ||
from .pokemons import firstgen | ||
#from .pokemons import firstgen | ||
|
||
|
||
class Pokinator: | ||
_name1 = firstgen._name1 | ||
_name2 = firstgen._name2 | ||
|
||
@classmethod | ||
def generate(self, token_range=9999, delimiter='-', digit=None): | ||
if not isinstance(token_range, int) or token_range < 0: | ||
raise RuntimeError('Token range must be a nonnegative integer') | ||
if not isinstance(delimiter, str): | ||
raise RuntimeError('Delimiter must be a string') | ||
|
||
generated = [choice(self._name1), choice(self._name2)] | ||
if digit != None: | ||
|
||
if digit is not None: | ||
if not isinstance(digit, int) or (digit < 1) or (digit < len(str(token_range))): | ||
raise RuntimeError('Digit must be more than 0') | ||
format_str = '%0.' + str(digit) + 'd' | ||
result = format_str % randint(0, token_range) | ||
else: | ||
result = randint(0, token_range) | ||
generated.append(str(result)) | ||
|
||
return delimiter.join(generated) | ||
|
||
return delimiter.join(generated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters