Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TASK_14_Behavioural_Observer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
arun.uday
TASK_14_Behavioural_Observer
Commits
d3273873
Commit
d3273873
authored
Feb 17, 2023
by
arun.uday
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit2
parent
b87af869
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
0 deletions
+21
-0
scripts/constants/api_response.py
scripts/constants/api_response.py
+2
-0
scripts/core/handlers/generate_new_movie.py
scripts/core/handlers/generate_new_movie.py
+8
-0
scripts/core/handlers/marvel_fans.py
scripts/core/handlers/marvel_fans.py
+4
-0
scripts/core/handlers/movie_observe.py
scripts/core/handlers/movie_observe.py
+4
-0
scripts/core/handlers/new_marve_movie.py
scripts/core/handlers/new_marve_movie.py
+2
-0
scripts/services/api_service_observe.py
scripts/services/api_service_observe.py
+1
-0
No files found.
scripts/constants/api_response.py
View file @
d3273873
# for sending response to the api
response_data
=
[]
response_data
=
[]
# creating the response message
def
response_data_
(
fan_name
,
movie
):
def
response_data_
(
fan_name
,
movie
):
responses
=
{
"message"
:
"New Marvel Movie Released"
,
responses
=
{
"message"
:
"New Marvel Movie Released"
,
"Status"
:
"Movie Found"
,
"Status"
:
"Movie Found"
,
...
...
scripts/core/handlers/generate_new_movie.py
View file @
d3273873
...
@@ -3,13 +3,21 @@ from scripts.core.handlers.new_marve_movie import NewMarvelMovie
...
@@ -3,13 +3,21 @@ from scripts.core.handlers.new_marve_movie import NewMarvelMovie
from
scripts.logging.loggers
import
logger
from
scripts.logging.loggers
import
logger
# Creating the objects of the class and adding the fans for getting the notifications
def
add_new_marvel
(
movie
):
def
add_new_marvel
(
movie
):
try
:
try
:
# creating the marvel movie
obj_movie
=
NewMarvelMovie
()
obj_movie
=
NewMarvelMovie
()
# creating the fans
fan_boy1
=
marvel_fans
.
Fan1
()
fan_boy1
=
marvel_fans
.
Fan1
()
fan_boy2
=
marvel_fans
.
Fan2
()
fan_boy2
=
marvel_fans
.
Fan2
()
# attaching fans to the observer
obj_movie
.
attach
(
fan_boy1
)
obj_movie
.
attach
(
fan_boy1
)
obj_movie
.
attach
(
fan_boy2
)
obj_movie
.
attach
(
fan_boy2
)
# creating the movie
obj_movie
.
movie_create
(
movie
)
obj_movie
.
movie_create
(
movie
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Exception occurred: "
,
e
)
logger
.
error
(
"Exception occurred: "
,
e
)
...
...
scripts/core/handlers/marvel_fans.py
View file @
d3273873
...
@@ -2,19 +2,23 @@ from scripts.constants.api_response import response_data, response_data_
...
@@ -2,19 +2,23 @@ from scripts.constants.api_response import response_data, response_data_
from
scripts.logging.loggers
import
logger
from
scripts.logging.loggers
import
logger
# fan 1
class
Fan1
:
class
Fan1
:
@
staticmethod
@
staticmethod
def
update
(
movie
):
def
update
(
movie
):
try
:
try
:
# appending to the response message
response_data
.
append
(
response_data_
(
"Fan 1"
,
movie
))
response_data
.
append
(
response_data_
(
"Fan 1"
,
movie
))
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Exception occurred: "
,
e
)
logger
.
error
(
"Exception occurred: "
,
e
)
# fan 2
class
Fan2
:
class
Fan2
:
@
staticmethod
@
staticmethod
def
update
(
movie
):
def
update
(
movie
):
try
:
try
:
# appending to the response message
response_data
.
append
(
response_data_
(
"Fan 2"
,
movie
))
response_data
.
append
(
response_data_
(
"Fan 2"
,
movie
))
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Exception occurred: "
,
e
)
logger
.
error
(
"Exception occurred: "
,
e
)
scripts/core/handlers/movie_observe.py
View file @
d3273873
class
MovieObserveStatus
:
class
MovieObserveStatus
:
# initializing the list for storing fans to get the movie notifications
def
__init__
(
self
):
def
__init__
(
self
):
self
.
fans
=
[]
self
.
fans
=
[]
# notify the fans in subscribe for the notification
def
notify
(
self
,
new_fan
=
None
):
def
notify
(
self
,
new_fan
=
None
):
for
fan
in
self
.
fans
:
for
fan
in
self
.
fans
:
if
new_fan
!=
fan
:
if
new_fan
!=
fan
:
fan
.
update
(
self
)
fan
.
update
(
self
)
# append the fan to the fans list
def
attach
(
self
,
fan
):
def
attach
(
self
,
fan
):
if
fan
not
in
self
.
fans
:
if
fan
not
in
self
.
fans
:
self
.
fans
.
append
(
fan
)
self
.
fans
.
append
(
fan
)
# remove the fans from the list
def
detach
(
self
,
fan
):
def
detach
(
self
,
fan
):
self
.
fans
.
remove
(
fan
)
self
.
fans
.
remove
(
fan
)
scripts/core/handlers/new_marve_movie.py
View file @
d3273873
...
@@ -7,6 +7,7 @@ from scripts.logging.loggers import logger
...
@@ -7,6 +7,7 @@ from scripts.logging.loggers import logger
class
NewMarvelMovie
(
MovieObserveStatus
):
class
NewMarvelMovie
(
MovieObserveStatus
):
def
__init__
(
self
):
def
__init__
(
self
):
try
:
try
:
# initializing the movie details
MovieObserveStatus
.
__init__
(
self
)
MovieObserveStatus
.
__init__
(
self
)
self
.
movie_name
=
str
self
.
movie_name
=
str
self
.
movie_director
=
str
self
.
movie_director
=
str
...
@@ -17,6 +18,7 @@ class NewMarvelMovie(MovieObserveStatus):
...
@@ -17,6 +18,7 @@ class NewMarvelMovie(MovieObserveStatus):
def
movie_create
(
self
,
movie
):
def
movie_create
(
self
,
movie
):
try
:
try
:
# storing the movie data
self
.
movie_name
=
movie
.
movie_name
self
.
movie_name
=
movie
.
movie_name
self
.
movie_director
=
movie
.
movie_director
self
.
movie_director
=
movie
.
movie_director
self
.
movie_stars
=
movie
.
movie_stars
self
.
movie_stars
=
movie
.
movie_stars
...
...
scripts/services/api_service_observe.py
View file @
d3273873
...
@@ -12,6 +12,7 @@ marvel_movies = APIRouter()
...
@@ -12,6 +12,7 @@ marvel_movies = APIRouter()
@
marvel_movies
.
post
(
api_path_config
.
route_index
)
@
marvel_movies
.
post
(
api_path_config
.
route_index
)
def
get_movie_details
(
movie
:
Marvel
):
def
get_movie_details
(
movie
:
Marvel
):
try
:
try
:
# creating the movie
add_new_marvel
(
movie
)
add_new_marvel
(
movie
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Interruption occurred: "
,
e
)
logger
.
error
(
"Interruption occurred: "
,
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment