-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a0c4843
commit c83b42a
Showing
9 changed files
with
440 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import ctypes | ||
|
||
|
||
class AnArray: | ||
""" | ||
Creates an array and gives some tools to work with it. | ||
""" | ||
def __init__(self, size): | ||
""" | ||
Creates an array with the length size. | ||
:param size: the size of the array. | ||
""" | ||
assert size > 0, "Array size must be > 0" | ||
self._size = size | ||
pyarraytype = ctypes.py_object * size | ||
self._elements = pyarraytype() | ||
for i in range(len(self)): | ||
self._elements[i] = None | ||
|
||
def __len__(self): | ||
""" | ||
Returns the length of the array. | ||
:return: the size of the array. | ||
""" | ||
return self._size | ||
|
||
def __getitem__(self, index): | ||
""" | ||
Gets the value of the element. | ||
:param index: the index of element. | ||
:return: value of the element. | ||
""" | ||
if not 0 <= index < self._size: | ||
raise IndexError('Invalid index') | ||
return self._elements[index] | ||
|
||
def __setitem__(self, index, value): | ||
""" | ||
Puts the value in the array element at index position. | ||
:param index: the index element. | ||
:param value: the value of element. | ||
""" | ||
if not 0 <= index < self._size: | ||
raise IndexError('Invalid index') | ||
self._elements[index] = value |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from modules.work_with_a_file import WorkWithAFile | ||
from modules.series_research import SeriesResearch | ||
from modules.an_array import AnArray | ||
|
||
# a = WorkWithAFile("ratings.txt") | ||
# a1 = a.open_file() | ||
# print(a.make_list(a1)) | ||
|
||
|
||
def popular_actors(): | ||
pass | ||
|
||
|
||
def the_earliest_series(): | ||
pass | ||
|
||
|
||
def series_names(): | ||
pass | ||
|
||
|
||
def main(): | ||
pass |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from pytvdbapi import api | ||
from modules.an_array import AnArray | ||
|
||
db = api.TVDB("1D6897F57A08B0BA") | ||
|
||
|
||
class SeriesResearch: | ||
""" | ||
Implements the SeriesResearch ADT for doing | ||
research based of the information about series. | ||
""" | ||
|
||
def __init__(self, length): | ||
""" | ||
Creates an array. | ||
:param length: the length of a created array. | ||
""" | ||
self.allseries = AnArray(length) | ||
|
||
def get_item(self, index): | ||
""" | ||
Gets the value of the element. | ||
:param index: the index of the element. | ||
:return: value of the element. | ||
""" | ||
return self.allseries.__getitem__(index) | ||
|
||
def set_item(self, index, value): | ||
""" | ||
Puts the value in the array element at index position. | ||
:param index: the index the element. | ||
:param value: the value of the element. | ||
""" | ||
self.allseries.__setitem__(index, value) | ||
|
||
def get_actors(self, index): | ||
""" | ||
Gets actors from series (the value of the element is | ||
the name of series). | ||
:param index: the index of the element. | ||
:return: the list of actors. | ||
""" | ||
series = self.get_item(index) | ||
actors = [] | ||
result = db.search(str(series), "en") | ||
show = result[0] | ||
show.load_actors() | ||
for actor in range(len(show.actor_objects)): | ||
actors.append(show.actor_objects[actor].Name) | ||
return actors | ||
|
||
def seasons_number(self, index): | ||
""" | ||
Gets the number of seasons in the given series | ||
(the value of the element is the name of series). | ||
:param index: the index of the element. | ||
:return: the number of seasons. | ||
""" | ||
series = self.get_item(index) | ||
result = db.search(str(series), "en") | ||
show = result[0] | ||
return len(show) |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Class WorkWithAFile is created to read information from a file | ||
# ratings.txt and to convert it into a list of series names. | ||
|
||
|
||
class WorkWithAFile: | ||
""" | ||
Contains functions open_file() and make_list(). | ||
To work with this class you should specify a filename. | ||
""" | ||
|
||
def __init__(self, filename): | ||
""" | ||
Creates an empty list. | ||
:param filename: the name of a file. | ||
""" | ||
self.series = [] | ||
self.filename = filename | ||
|
||
def open_file(self): | ||
""" | ||
Opens a file and saves all the information in a list | ||
(split by newlines). | ||
:return: a list with all the information from the file. | ||
""" | ||
all_series = [] | ||
openfile = open(self.filename, encoding="utf-8") | ||
whole_file = openfile.readline() | ||
while not whole_file.endswith("Forgotten Lady (Season 5, Episode 1)"): | ||
whole_file = openfile.readline() | ||
all_series.append(whole_file) | ||
return all_series | ||
|
||
def make_list(self, lst): | ||
""" | ||
Creates a list of series names. | ||
:param lst: a list with all the information from the file. | ||
:return: a list of series names. | ||
""" | ||
for i in range(0, len(lst), 5): | ||
if i < 45: | ||
self.series.append(lst[i][3:-1]) | ||
else: | ||
self.series.append(lst[i][4:-1]) | ||
for name in range(len(self.series)): | ||
if "(" in self.series[name]: | ||
self.series[name] = self.series[name][:self.series[name].index("(") - 1] | ||
return self.series |