Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tweet_model
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
serpucga
tweet_model
Commits
97efa2ff
Commit
97efa2ff
authored
Mar 25, 2019
by
Serbaf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed prints for logs and sys.exit for exceptions
parent
90680e39
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
tweet_model.py
tweet_model/tweet_model.py
+15
-3
No files found.
tweet_model/tweet_model.py
View file @
97efa2ff
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""Main module."""
"""Main module."""
import
logging
import
sys
import
sys
from
tweet_manager.lib
import
format_csv
from
tweet_manager.lib
import
format_csv
# Configure logger
LOG_FORMAT
=
'[
%(asctime)-15
s]
%(levelname)
s:
%(message)
s'
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
LOG_FORMAT
)
logger
=
logging
.
getLogger
(
"logger"
)
class
Tweet
():
class
Tweet
():
"""
"""
...
@@ -358,6 +364,10 @@ class Tweet():
...
@@ -358,6 +364,10 @@ class Tweet():
return
getattr
(
self
,
key
)
return
getattr
(
self
,
key
)
class
NotValidTweetError
(
Exception
):
pass
def
get_tweets_from_csv
(
csv_file
):
def
get_tweets_from_csv
(
csv_file
):
"""
"""
Take one argument: a path pointing to a valid CSV file.
Take one argument: a path pointing to a valid CSV file.
...
@@ -385,9 +395,11 @@ def get_tweets_from_csv(csv_file):
...
@@ -385,9 +395,11 @@ def get_tweets_from_csv(csv_file):
for
component
in
field_components
:
for
component
in
field_components
:
error_string
+=
component
error_string
+=
component
if
(
checking_dict
is
None
)
or
(
component
not
in
checking_dict
):
if
(
checking_dict
is
None
)
or
(
component
not
in
checking_dict
):
print
(
'The field in the header "'
+
error_string
+
'" is '
+
logger
.
error
(
'The field in the header "{error_string}" '
+
'not a valid element of a Tweet'
)
'is not a valid element of a Tweet'
)
sys
.
exit
(
1
)
raise
NotValidTweetError
(
"Header contains field which doesn't"
+
" belong to tweet specification: "
+
error_string
)
checking_dict
=
checking_dict
[
component
]
checking_dict
=
checking_dict
[
component
]
error_string
+=
"."
error_string
+=
"."
...
...
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