Skip to content

Commit

Permalink
docs: add documentation string
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsanima committed Jun 14, 2021
1 parent b45720c commit 7faf2b0
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 20 deletions.
86 changes: 76 additions & 10 deletions src/mdsanima_dev/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ def emoji_clean_url_data(


def emoji_load_json_data() -> dict:
"""
This function loading the json data generated on previous function.
Returns:
dict: Dictionary json all emoji with joining two json.
"""
with open(HERE / 'json/emoji-list.json', 'r', encoding='utf-8') as dt:
emo_lis = json.load(dt)
with open(HERE / 'json/emoji-modifiers.json', 'r', encoding='utf-8') as dt:
Expand All @@ -245,10 +251,17 @@ def emoji_load_json_data() -> dict:


class emoji:
"""
This class has methods for printing various emoji functions.
"""
def __init__(self):
self.mds = colors.get_complex_color

def emo_stats(self):
"""
This method printing the statistic of emoji with colors in the table.
"""
# Get all value of emoji in json files.
e_stats = self.emo[self.emo_list]['src']['emoji_stats']
e_data = self.emo[self.emo_list]['src']['emoji_data']
e_heder = str(self.emo_list).replace("_", ' ').upper().ljust(21)
Expand All @@ -272,6 +285,11 @@ def emo_stats(self):
.ljust(29), 111, 104, True, False, t_col)

def emo_big_head(self):
"""
This method printing all big head text value of emoji with colors
in the table.
"""
# Get all value of emoji in json files.
e_head = self.emo[self.emo_list]['emo']
e_heder = str('BIG HEAD').upper().ljust(21)

Expand All @@ -287,6 +305,11 @@ def emo_big_head(self):
self.tab(t_col).bot(32)

def emo_medium_head(self):
"""
This method printing all medium head text value of emoji with colors
in the table.
"""
# Get all value of emoji in json files.
e_head = self.emo[self.emo_list]['emo']
e_heder = str('MEDIUM HEAD').upper().ljust(21)

Expand All @@ -307,6 +330,15 @@ def emo_medium_head(self):
self.tab(t_col).bot(32)

def emo_all(self, number: bool = False, names: bool = False):
"""
This method prints all available emojis, sorted by heads.
You can use the option to print number of emoji and names of emoji.
Args:
number (bool, optional): Print emoji numbers. Defaults to False.
names (bool, optional): Print emoji names. Defaults to False.
"""
# Get all value of emoji in json files.
e_head = self.emo[self.emo_list]['emo']
e_heder = str('EMOJI').upper().ljust(21)

Expand Down Expand Up @@ -334,8 +366,19 @@ def emo_all(self, number: bool = False, names: bool = False):
self.mds(str(name), 243, '\n')) if names else ''
print('\n')

def emo_head(self, bhead, mhead,
number: bool = False, names: bool = False):
def emo_head(self, bhead: str, mhead: str,
number: bool = False, names: bool = False
):
"""
This method pringing all emoji in head.
Args:
bhead (str): Name of big head emoji.
mhead (str): Name of medium head emoji.
number (bool, optional): Print emoji numbers. Defaults to False.
names (bool, optional): Print emoji names. Defaults to False.
"""
# Get all value of emoji in json files.
e_head = self.emo[self.emo_list]['emo']

# Initial table color variable.
Expand All @@ -361,7 +404,16 @@ def emo_head(self, bhead, mhead,
chk = 1 if names else print('\r')

def emoji(self, number: int):
"""
Serching of emoji numer and break.
Args:
number (int): Emoji number to printing.
"""
# Get all value of emoji in json files.
e_head = self.emo[self.emo_list]['emo']

# Searching of specific number of emoji and break.
for key_bh in e_head:
for key_mh in e_head[key_bh]:
for key_name in e_head[key_bh][key_mh]:
Expand All @@ -372,18 +424,32 @@ def emoji(self, number: int):


class show(emoji):
"""
This class show all emoji.
Args:
emoji (class): Master class of emoji.
Usage:
.. code::
show('emoji_list').emo_stats()
show('emoji_list').emo_big_head()
show('emoji_list').emo_medium_head()
show('emoji_list').emo_all(True, False)
show('emoji_list').emo_head('objects', 'music', True, True)
show('emoji_list').emoji(1813)
"""
def __init__(self, emo_list) -> emoji:
"""
Initial function.
Args:
emo_list (str): Name `emoji_list` and `emoji_modifiers` only.
Returns:
emoji: Pringitn value of specific emoji method.
"""
self.emo = emoji_load_json_data()
self.mds = colors.get_complex_color
self.head = table().headers
self.cont = table().content
self.emo_list = emo_list
self.tab = table_elem


# show('emoji_list').emo_stats()
# show('emoji_list').emo_big_head()
# show('emoji_list').emo_medium_head()
# show('emoji_list').emo_all(True, False)
# show('emoji_list').emo_head('objects', 'music', True, True)
# show('emoji_list').emoji(1813)
120 changes: 115 additions & 5 deletions src/mdsanima_dev/utils/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,34 @@


class table:
"""
This class create template table with colors, headers and content.
"""
def __init__(self):
self.mds = colors.get_complex_color

def colors(self, color:int=255) -> int:
"""
Initial color table.
Args:
color (int, optional): Color of the table. Defaults to 255.
Returns:
int: Number of colors from `colors` module.
"""
self.tab_color = color

def connect(self, top: bool, length: int, bot: bool) -> str:
"""
Checking for connecting table.
Args:
top (bool): Top element of the table.
length (int): Length of the table.
bot (bool): Bottom element of the table.
Returns:
str: Element printing of the table in unicode value.
"""
header = ('\u250c' + ('\u2500' * length) + '\u2510')
conect = ('\u251c' + ('\u2500' * length) + '\u2524')
bottom = ('\u2514' + ('\u2500' * length) + '\u2518')
Expand All @@ -26,7 +47,20 @@ def connect(self, top: bool, length: int, bot: bool) -> str:
def headers(self,
header: str, hcolor: int = 255,
top: bool = False, bot: bool = False,
tcolor: int = 255) -> str:
tcolor: int = 255
) -> str:
"""
Headers of the template table.
Args:
header (str): Headers with connectiog or nor.
hcolor (int, optional): Color of text. Defaults to 255.
top (bool, optional): Check connecting top. Defaults to False.
bot (bool, optional): Check connection bootom. Defaults to False.
tcolor (int, optional): Table color. Defaults to 255.
Returns:
str: Headers element of tempalte table.
"""
self.header = header
self.color = hcolor
head_len = len(self.header) + 2
Expand All @@ -50,7 +84,22 @@ def content(self,
content_key: str, content_val: str,
key_color: int = 255, val_color: int = 255,
top: bool = False, bot: bool = False,
tcolor: int = 255) -> str:
tcolor: int = 255
) -> str:
"""
Content of the tempalte table. This table constrain two text value.
Args:
content_key (str): First text value in the left.
content_val (str): Second text value in the right.
key_color (int, optional): Text color content key. Defaults to 255.
val_color (int, optional): Text color content val. Defaults to 255.
top (bool, optional): Check connecting top. Defaults to False.
bot (bool, optional): Check connecting bootom. Defaults to False.
tcolor (int, optional): Table color. Defaults to 255.
Returns:
str: Content elemento of template table.
"""
self.key = content_key
self.val = content_val
self.key_col = key_color
Expand Down Expand Up @@ -81,30 +130,91 @@ def content(self,


class table_elem:
"""
Element of the table to create your own, what you want.
"""
def __init__(self, color: int) -> str:
"""
Initial finction.
Args:
color (int): Number of colors from `colors` module.
Returns:
str: Color value.
"""
self.mds = colors.get_complex_color
self.color = color

def top(self, length: int) -> str:
"""
Top element of the table.
Args:
length (int): Length of the table element.
Returns:
str: Unicode top element printing in one line.
"""
self.header = ('\u250c' + ('\u2500' * length) + '\u2510')
self.mds(self.header, self.color)

def mid(self, length: int) -> str:
"""
Midle element of the table.
Args:
length (int): Length of the table element.
Returns:
str: Unicode midle element printing in one line.
"""
self.middle = ('\u251c' + ('\u2500' * length) + '\u2524')
self.mds(self.middle, self.color)

def bot(self, length: int) -> str:
"""
Bootom element of the table.
Args:
length (int): Length of the table element.
Returns:
str: Unicode bootom element printing in one line.
"""
self.bottom = ('\u2514' + ('\u2500' * length) + '\u2518')
self.mds(self.bottom, self.color)

def hed(self, length: int, text: str, text_color: int) -> str:
def hed(self,
length: int, text: str, text_color: int
) -> str:
"""
Header element of the table one text value.
Args:
length (int): Length of the table element.
text (str): Text printing inside table.
text_color (int): Text color.
Returns:
str: Unicode header element printing in one line.
"""
self.text = text.ljust(length-1)
self.mds('\u2502', self.color, '')
self.mds(' ' + self.text.upper(), text_color, '')
self.mds('\u2502', self.color)

def con(self, length: int, key: str, val: str,
k_clr: int, v_clr: int) -> str:
def con(self,
length: int, key: str, val: str,
k_clr: int, v_clr: int
) -> str:
"""
Content element of the table two text value.
Args:
length (int): Length of the table element.
key (str): Text printing inside table in the left.
val (str): Text printing inside table in the right.
k_clr (int): Text color key.
v_clr (int): Text color val.
Returns:
str: Unicode content element printing in one line.
"""
self.con_key = key
self.con_val = val
k_len = len(key)
Expand Down

0 comments on commit 7faf2b0

Please sign in to comment.