homa 0.15__py3-none-any.whl → 0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- homa/repositories/RandomDateRepository.py +62 -0
- homa/repositories/RandomImageRepository.py +2 -0
- homa/repositories/RandomNameRepository.py +66 -0
- homa/repositories/RandomTextRepository.py +24 -0
- homa/repositories/__init__.py +4 -0
- {homa-0.15.dist-info → homa-0.16.dist-info}/METADATA +2 -2
- homa-0.16.dist-info/RECORD +13 -0
- homa-0.15.dist-info/RECORD +0 -8
- {homa-0.15.dist-info → homa-0.16.dist-info}/LICENSE +0 -0
- {homa-0.15.dist-info → homa-0.16.dist-info}/WHEEL +0 -0
- {homa-0.15.dist-info → homa-0.16.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from ..helpers import randint
|
|
2
|
+
import datetime
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class RandomDateRepository:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.generatedYear = None
|
|
8
|
+
self.generatedMonth = None
|
|
9
|
+
self.generatedDay = None
|
|
10
|
+
self.dayCounts = {
|
|
11
|
+
1: 31, # January
|
|
12
|
+
2: 28, # February
|
|
13
|
+
3: 31, # March
|
|
14
|
+
4: 30, # April
|
|
15
|
+
5: 31, # May
|
|
16
|
+
6: 30, # June
|
|
17
|
+
7: 31, # July
|
|
18
|
+
8: 31, # August
|
|
19
|
+
9: 30, # September
|
|
20
|
+
10: 31, # October
|
|
21
|
+
11: 30, # November
|
|
22
|
+
12: 31 # December
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def year(self, start: int = 2000, end: int = 2020) -> int:
|
|
26
|
+
self.generatedYear = randint(start, end + 1)
|
|
27
|
+
self.isLeap = self.generatedYear % 4 == 0
|
|
28
|
+
|
|
29
|
+
if self.isLeap:
|
|
30
|
+
self.dayCounts[2] = 29
|
|
31
|
+
else:
|
|
32
|
+
self.dayCounts[2] = 28
|
|
33
|
+
|
|
34
|
+
return self.generatedYear
|
|
35
|
+
|
|
36
|
+
def month(self) -> int:
|
|
37
|
+
self.generatedMonth = randint(1, 12 + 1)
|
|
38
|
+
return self.generatedMonth
|
|
39
|
+
|
|
40
|
+
def day(self) -> int:
|
|
41
|
+
self.generatedDay = randint(1, self.dayCounts[self.generatedMonth])
|
|
42
|
+
return self.generatedDay
|
|
43
|
+
|
|
44
|
+
def date(self, asString=False, separator="/"):
|
|
45
|
+
if asString:
|
|
46
|
+
return f"{self.year()}{separator}{self.month()}{separator}{self.day()}"
|
|
47
|
+
|
|
48
|
+
return datetime.datetime(
|
|
49
|
+
self.year(),
|
|
50
|
+
self.month(),
|
|
51
|
+
self.day()
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def datetime(self):
|
|
55
|
+
return datetime.datetime(
|
|
56
|
+
self.year(),
|
|
57
|
+
self.month(),
|
|
58
|
+
self.day(),
|
|
59
|
+
randint(0, 23 + 1),
|
|
60
|
+
randint(0, 60),
|
|
61
|
+
randint(0, 60),
|
|
62
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from random import shuffle
|
|
2
|
+
|
|
3
|
+
from ..helpers import fileAsArray
|
|
4
|
+
from ..helpers import oneOf
|
|
5
|
+
from ..helpers import root
|
|
6
|
+
from ..helpers import replaceVowels
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RandomNameRepository:
|
|
10
|
+
def __init__(self) -> None:
|
|
11
|
+
self.__masculine_firstnames = fileAsArray(
|
|
12
|
+
root("wordlists/names/masculine_names.txt")
|
|
13
|
+
)
|
|
14
|
+
self.__feminine_firstnames = fileAsArray(
|
|
15
|
+
root("wordlists/names/feminine_names.txt")
|
|
16
|
+
)
|
|
17
|
+
self.__surnames = fileAsArray(
|
|
18
|
+
root("wordlists/names/surnames.txt")
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
shuffle(self.__masculine_firstnames)
|
|
22
|
+
shuffle(self.__feminine_firstnames)
|
|
23
|
+
shuffle(self.__surnames)
|
|
24
|
+
|
|
25
|
+
self.lastGender = None
|
|
26
|
+
|
|
27
|
+
def gender(self, gender: str | None):
|
|
28
|
+
genderMap = {
|
|
29
|
+
"girl": "F",
|
|
30
|
+
"girls": "F",
|
|
31
|
+
"female": "F",
|
|
32
|
+
"boy": "M",
|
|
33
|
+
"male": "M"
|
|
34
|
+
}
|
|
35
|
+
self.lastGender = oneOf(
|
|
36
|
+
["F", "M"]) if not gender else genderMap[gender]
|
|
37
|
+
|
|
38
|
+
def firstname(self) -> str:
|
|
39
|
+
targetArrayMap = {
|
|
40
|
+
"M": self.__masculine_firstnames,
|
|
41
|
+
"F": self.__feminine_firstnames,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return oneOf(targetArrayMap[self.lastGenderOrRandom()])
|
|
45
|
+
|
|
46
|
+
def surname(self) -> str:
|
|
47
|
+
return replaceVowels(oneOf(self.__surnames))
|
|
48
|
+
|
|
49
|
+
def prefix(self):
|
|
50
|
+
targetArrayMap = {
|
|
51
|
+
"M": ["Lord", "Sir", "Gentleman", "Dr."],
|
|
52
|
+
"F": ["Madam", "Dr.", "Miss", "Ms."]
|
|
53
|
+
}
|
|
54
|
+
return oneOf(targetArrayMap[self.lastGenderOrRandom()])
|
|
55
|
+
|
|
56
|
+
def lastGenderOrRandom(self):
|
|
57
|
+
return self.lastGender if self.lastGender else oneOf(["M", "F"])
|
|
58
|
+
|
|
59
|
+
def fullname(self, gender=None):
|
|
60
|
+
self.gender(gender)
|
|
61
|
+
|
|
62
|
+
usePrefix = oneOf([True, False])
|
|
63
|
+
if usePrefix:
|
|
64
|
+
return f"{self.prefix()} {self.firstname()} {self.surname()}"
|
|
65
|
+
|
|
66
|
+
return f"{self.firstname()} {self.surname()}"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import string
|
|
2
|
+
import random
|
|
3
|
+
|
|
4
|
+
from ..helpers import randint
|
|
5
|
+
from ..helpers import oneOf
|
|
6
|
+
from ..helpers import fileAsArray
|
|
7
|
+
from ..helpers import root
|
|
8
|
+
from ..helpers import replaceVowels
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RandomTextRepository:
|
|
12
|
+
def __init__(self) -> None:
|
|
13
|
+
self.titles = fileAsArray(
|
|
14
|
+
root("wordlists/text/titles.txt")
|
|
15
|
+
)
|
|
16
|
+
random.shuffle(self.titles)
|
|
17
|
+
|
|
18
|
+
def token(self, lowerBound: int = 4, upperBound: int = 14):
|
|
19
|
+
letters = list(string.ascii_lowercase)
|
|
20
|
+
random.shuffle(letters)
|
|
21
|
+
return "".join(letters[:randint(lowerBound, upperBound)])
|
|
22
|
+
|
|
23
|
+
def title(self):
|
|
24
|
+
return replaceVowels(oneOf(self.titles))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: homa
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16
|
|
4
4
|
Description-Content-Type: text/markdown
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ License-File: LICENSE
|
|
|
15
15
|
|
|
16
16
|
Homa is a library to generate random data that provides more productivity for developers.
|
|
17
17
|
|
|
18
|
-
In loving memory of [Saber Rastikerdar](https://rastikerdar.github.io/), who introduced Persian to the digital world. 🖤💚
|
|
18
|
+
In loving memory of [Saber Rastikerdar](https://rastikerdar.github.io/), who introduced Persian (Farsi) to the digital world. 🖤💚
|
|
19
19
|
|
|
20
20
|
## Names
|
|
21
21
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
homa/__init__.py,sha256=iPxn6CB50Dt59fYKMBO8yGlAwgFy5HscFPx786CVpSA,69
|
|
2
|
+
homa/helpers.py,sha256=iE_0H0iePqqVjc1iOgozf0mKOXb9XHH44bg0jyX9xLg,5596
|
|
3
|
+
homa/main.py,sha256=2TvPspiYUi-eCJUbXRCWnFtbPNCYIcneSFBtnz65zNc,936
|
|
4
|
+
homa/repositories/RandomDateRepository.py,sha256=1fK_oPJ1ln-3Zs4O3eOhh427LeM48PNvXeGDJYV8d4o,1659
|
|
5
|
+
homa/repositories/RandomImageRepository.py,sha256=YxWP1hjDXk8yncBivINq2WTSXI1bNQ5zvHI2ckcrXLw,38
|
|
6
|
+
homa/repositories/RandomNameRepository.py,sha256=12DgWKNT6SyZgpj52CNd-_Z6tT7AxEVcQ9KVPLpuMBQ,1899
|
|
7
|
+
homa/repositories/RandomTextRepository.py,sha256=OHWLSTUftYZT-NaOUlkN4uI1JQW4KRwrmSuFs27su9A,654
|
|
8
|
+
homa/repositories/__init__.py,sha256=11Dv_PG1H9sEy0SdxdYzisXegnjoVrZBPFJ3wNrZnzc,221
|
|
9
|
+
homa-0.16.dist-info/LICENSE,sha256=js3WDbJn9k5EN6sy1uuP2QBXxyPgS5DjO4Bf5yE35hQ,1072
|
|
10
|
+
homa-0.16.dist-info/METADATA,sha256=jpr0KfLgoDfmZAnmWN506cwq2SZRqrSVFkLyPLOT5IQ,893
|
|
11
|
+
homa-0.16.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
12
|
+
homa-0.16.dist-info/top_level.txt,sha256=tmOfy2tuaAwc3W5-i6j61_vYJsXgR4ivBWkhJ3ZtJDc,5
|
|
13
|
+
homa-0.16.dist-info/RECORD,,
|
homa-0.15.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
homa/__init__.py,sha256=iPxn6CB50Dt59fYKMBO8yGlAwgFy5HscFPx786CVpSA,69
|
|
2
|
-
homa/helpers.py,sha256=iE_0H0iePqqVjc1iOgozf0mKOXb9XHH44bg0jyX9xLg,5596
|
|
3
|
-
homa/main.py,sha256=2TvPspiYUi-eCJUbXRCWnFtbPNCYIcneSFBtnz65zNc,936
|
|
4
|
-
homa-0.15.dist-info/LICENSE,sha256=js3WDbJn9k5EN6sy1uuP2QBXxyPgS5DjO4Bf5yE35hQ,1072
|
|
5
|
-
homa-0.15.dist-info/METADATA,sha256=JkRONEQ69fkrLC64n0y7lVExrGP-7pj2EQjcsNyxgds,885
|
|
6
|
-
homa-0.15.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
7
|
-
homa-0.15.dist-info/top_level.txt,sha256=tmOfy2tuaAwc3W5-i6j61_vYJsXgR4ivBWkhJ3ZtJDc,5
|
|
8
|
-
homa-0.15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|