Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
shadowban-eu-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
shadowban-eu-backend
Commits
fd177757
Commit
fd177757
authored
Dec 06, 2021
by
tsukumi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: code format
parent
74565dd8
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
34 additions
and
24 deletions
+34
-24
backend.py
backend.py
+2
-1
database.py
database.py
+2
-1
features.py
features.py
+0
-17
log.py
log.py
+2
-1
tests/__init__.py
tests/__init__.py
+1
-0
tests/ghostban.py
tests/ghostban.py
+1
-0
tests/profile.py
tests/profile.py
+20
-2
tests/reply_deboosting.py
tests/reply_deboosting.py
+1
-0
tests/typeahead.py
tests/typeahead.py
+1
-0
twitter_session.py
twitter_session.py
+3
-2
util.py
util.py
+1
-0
No files found.
backend.py
View file @
fd177757
import
argparse
import
asyncio
import
json
...
...
@@ -7,7 +8,7 @@ import time
from
aiohttp
import
web
import
daemon
from
d
b
import
connect
,
Database
from
d
atabase
import
connect
,
Database
from
log
import
log
,
add_file_handler
,
set_log_level
,
shutdown_logging
from
twitter_session
import
TwitterSession
...
...
d
b
.py
→
d
atabase
.py
View file @
fd177757
import
copy
from
time
import
sleep
from
pymongo
import
MongoClient
from
time
import
sleep
from
log
import
log
...
...
features.py
deleted
100644 → 0
View file @
74565dd8
# Count amount of "possibly_sensitive_editable" and "possibly_sensitive"
# flagged tweets in user's timeline
async
def
count_sensitives
(
session
,
user_id
):
profile_timeline
=
await
session
.
get_profile_tweets_raw
(
user_id
)
profile_tweets
=
profile_timeline
[
"globalObjects"
][
"tweets"
]
.
values
()
counted
=
len
(
profile_tweets
)
possibly_sensitive
=
len
([
1
for
tweet
in
profile_tweets
if
"possibly_sensitive"
in
tweet
.
keys
()])
possibly_sensitive_editable
=
len
([
1
for
tweet
in
profile_tweets
if
"possibly_sensitive_editable"
in
tweet
.
keys
()])
result
=
{
"counted"
:
counted
,
"possibly_sensitive"
:
possibly_sensitive
,
"possibly_sensitive_editable"
:
possibly_sensitive_editable
}
return
result
log.py
View file @
fd177757
import
gzip
import
logging
from
logging.handlers
import
TimedRotatingFileHandler
import
os
import
shutil
from
logging.handlers
import
TimedRotatingFileHandler
log_format
=
'
%(asctime)
s |
%(module)
s:
%(lineno)
d |
%(levelname)
s:
%(message)
s'
logging
.
basicConfig
(
format
=
log_format
)
...
...
tests/__init__.py
View file @
fd177757
from
tests.typeahead
import
test
as
test_typeahead
from
tests.ghostban
import
test
as
test_ghost_ban
from
tests.reply_deboosting
import
test
as
test_reply_deboosting
...
...
tests/ghostban.py
View file @
fd177757
import
traceback
from
log
import
log
...
...
tests/profile.py
View file @
fd177757
import
sys
import
pathlib
import
sys
from
typing
import
Any
,
Tuple
,
Dict
sys
.
path
.
insert
(
0
,
str
(
pathlib
.
Path
(
__file__
)
.
parent
))
from
features
import
count_sensitives
from
log
import
log
from
util
import
is_error
,
is_generic_error
,
UnexpectedApiError
# Count amount of "possibly_sensitive_editable" and "possibly_sensitive"
# flagged tweets in user's timeline
async
def
count_sensitives
(
session
,
user_id
):
profile_timeline
=
await
session
.
get_profile_tweets_raw
(
user_id
)
profile_tweets
=
profile_timeline
[
"globalObjects"
][
"tweets"
]
.
values
()
counted
=
len
(
profile_tweets
)
possibly_sensitive
=
len
([
1
for
tweet
in
profile_tweets
if
"possibly_sensitive"
in
tweet
.
keys
()])
possibly_sensitive_editable
=
len
([
1
for
tweet
in
profile_tweets
if
"possibly_sensitive_editable"
in
tweet
.
keys
()])
result
=
{
"counted"
:
counted
,
"possibly_sensitive"
:
possibly_sensitive
,
"possibly_sensitive_editable"
:
possibly_sensitive_editable
}
return
result
async
def
test
(
session
,
username
:
str
)
->
Tuple
[
str
,
Dict
[
str
,
Any
]]:
profile
:
dict
[
str
,
Any
]
=
{}
profile_raw
=
await
session
.
profile_raw
(
username
)
...
...
tests/reply_deboosting.py
View file @
fd177757
import
traceback
from
log
import
log
...
...
tests/typeahead.py
View file @
fd177757
import
urllib.parse
async
def
test
(
session
,
screen_name
):
...
...
twitter_session.py
View file @
fd177757
from
typing
import
Any
import
os
import
time
import
urllib
,
urllib
.
parse
import
os
from
typing
import
Any
import
aiohttp
from
bs4
import
BeautifulSoup
...
...
util.py
View file @
fd177757
def
get_nested
(
obj
,
path
,
default
=
None
):
for
p
in
path
:
if
obj
is
None
or
not
p
in
obj
:
...
...
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