Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
url = pw.CharField(null=True) # URL to json polygon of place boundary
bounding_box_coordinates = pw.CharField(null=True) # json list of 4 [lat, lon] pairs
class User(BaseModel):
id_str = pw.CharField(null=True) # v4
screen_name = pw.CharField(null=True)
verified = pw.BooleanField(null=True) # v4
time_zone = pw.CharField(null=True) # v4
utc_offset = pw.IntegerField(null=True) # -28800 (v4)
protected = pw.BooleanField(null=True) # v4
location = pw.CharField(null=True) # Houston, TX (v4)
lang = pw.CharField(null=True) # en (v4)
followers_count = pw.IntegerField(null=True)
created_date = pw.DateTimeField(default=datetime.datetime.now)
statuses_count = pw.IntegerField(null=True)
friends_count = pw.IntegerField(null=True)
favourites_count = pw.IntegerField(default=0)
class Tweet(BaseModel):
id_str = pw.CharField(null=True)
in_reply_to_id_str = pw.CharField(null=True, default=None)
in_reply_to = pw.ForeignKeyField('self', null=True, related_name='replies')
user = pw.ForeignKeyField(User, null=True, related_name='tweets')
source = pw.CharField(null=True) # e.g. "Twitter for iPhone"
text = pw.CharField(null=True)
tags = pw.CharField(null=True) # e.g. "#sarcasm #angry #trumped"
created_date = pw.DateTimeField(default=datetime.datetime.now)
location = pw.CharField(null=True)
place = pw.ForeignKeyField(Place, null=True)
favorite_count = pw.IntegerField(default=0)
class Meta:
table_name = 'site_metadata'
class Sub(BaseModel):
name = CharField(null=True, unique=True, max_length=32)
nsfw = BooleanField(default=False)
sid = CharField(primary_key=True, max_length=40)
sidebar = TextField(default='')
status = IntegerField(null=True)
title = CharField(null=True, max_length=50)
sort = CharField(null=True, max_length=32)
creation = DateTimeField(default=datetime.datetime.utcnow)
subscribers = IntegerField(default=1)
posts = IntegerField(default=0)
def __repr__(self):
return f'<sub>'
class Meta:
table_name = 'sub'
def get_metadata(self, key):
""" Returns `key` for submetadata or `None` if it does not exist.
Only works for single keys """
try:
m = SubMetadata.get((SubMetadata.sid == self.sid) & (SubMetadata.key == key))
return m.value
except SubMetadata.DoesNotExist:
return None
</sub>
started : int, optional
The position at which the playback started (only valid if action is
'play').
position : int, optional
The position at which the playback was stopped (only valid if action is
'play').
total : int, optional
The duration of the episode in seconds (only valid if action is
'play').
"""
episode = ForeignKeyField(Episode, on_delete='CASCADE')
action = TextField()
time = DateTimeField(default=datetime.utcnow)
started = IntegerField(null=True)
position = IntegerField(null=True)
total = IntegerField(null=True)
@property
def podcast_url(self):
"""str: the url of the episode's podcast."""
return self.episode.podcast.url
@property
def episode_url(self):
"""str: the url of the episode."""
return self.episode.file_url
@property
def timestamp(self):
"""str: the UTC time when the action took place as an ISO8601
timestamp."""
from peewee import CharField, DateTimeField, DecimalField, IntegerField, Model
from playhouse.postgres_ext import JSONField
from my_internet_speed.settings import DATABASE
class Result(Model):
download = DecimalField(index=True, max_digits=20, decimal_places=10)
upload = DecimalField(index=True, max_digits=20, decimal_places=10)
timestamp = DateTimeField(index=True)
ping = DecimalField(index=True, max_digits=10, decimal_places=5, null=True)
bytes_sent = IntegerField(null=True)
bytes_received = IntegerField(null=True)
server = JSONField(null=True)
client = JSONField(null=True)
url = CharField(max_length=64, null=True)
class Meta:
database = DATABASE
ex_data = model_to_dict(ex_data)
ex_data.update(data)
else:
ex_data = data
cls.insert(**ex_data).on_conflict_replace().execute()
return cls.get_or_none(**ex_data)
class FetchedUser(BaseModel):
uid = IntegerField(unique=True, primary_key=True)
name = CharField()
headPic = CharField()
status = IntegerField()
gossip = IntegerField()
album = IntegerField()
photo = IntegerField()
blog = IntegerField()
class User(BaseModel):
uid = IntegerField(unique=True, primary_key=True)
name = CharField()
headPic = CharField()
class Comment(BaseModel):
id = IntegerField(unique=True, primary_key=True)
t = DateTimeField(index=True)
entry_id = IntegerField(index=True)
entry_type = CharField(index=True)
(("_white_ipv6",), False),
)
PROTOCOLS = (
"http",
"socks4",
"socks5",
)
raw_protocol = peewee.SmallIntegerField(null=False)
domain = peewee.CharField(settings.DB_MAX_DOMAIN_LENGTH, null=False)
port = peewee.IntegerField(null=False)
auth_data = peewee.CharField(settings.DB_AUTH_DATA_MAX_LENGTH, default="", null=False)
checking_period = peewee.IntegerField(default=settings.MIN_PROXY_CHECKING_PERIOD, null=False)
last_check_time = peewee.IntegerField(default=0, null=False)
next_check_time = peewee.IntegerField(default=0, null=False)
number_of_bad_checks = peewee.IntegerField(default=0, null=False)
uptime = peewee.IntegerField(default=None, null=True)
bad_uptime = peewee.IntegerField(default=None, null=True)
# in microseconds
response_time = peewee.IntegerField(default=None, null=True)
# TODO: consider storing as binary
_white_ipv4 = peewee.CharField(16, null=True)
_white_ipv6 = peewee.CharField(45, null=True)
def get_raw_protocol(self):
return self.raw_protocol
@property
def location(self):
if location_database_reader is None:
# -*- encoding: utf-8 -*-
import peewee
import random
from discograph.library.sqlite.SqliteModel import SqliteModel
class SqliteRelation(SqliteModel):
### PEEWEE FIELDS ###
entity_one_id = peewee.IntegerField()
entity_one_type = peewee.IntegerField()
entity_two_id = peewee.IntegerField()
entity_two_type = peewee.IntegerField()
release_id = peewee.IntegerField(null=True)
role_name = peewee.CharField()
year = peewee.IntegerField(null=True)
### PEEWEE META ###
class Meta:
db_table = 'relation'
indexes = (
(('entity_one_id', 'entity_one_type', 'role_name', 'year'), False),
(('entity_two_id', 'entity_two_type', 'role_name', 'year'), False),
)
### PUBLIC METHODS ###
table_name = "sub_post_vote"
@migrator.create_model
class SubStylesheet(pw.Model):
xid = pw.PrimaryKeyField()
content = pw.TextField(null=True)
source = pw.TextField()
sid = pw.ForeignKeyField(backref='substylesheet_set', column_name='sid', field='sid', model=migrator.orm['sub'], null=True)
class Meta:
table_name = "sub_stylesheet"
@migrator.create_model
class SubSubscriber(pw.Model):
xid = pw.PrimaryKeyField()
order = pw.IntegerField(null=True)
sid = pw.ForeignKeyField(backref='subsubscriber_set', column_name='sid', field='sid', model=migrator.orm['sub'], null=True)
status = pw.IntegerField(null=True)
time = pw.DateTimeField()
uid = pw.ForeignKeyField(backref='subsubscriber_set', column_name='uid', field='uid', model=migrator.orm['user'], null=True)
class Meta:
table_name = "sub_subscriber"
@migrator.create_model
class SubUploads(pw.Model):
id = pw.AutoField()
sid = pw.ForeignKeyField(backref='subuploads_set', column_name='sid', field='sid', model=migrator.orm['sub'])
fileid = pw.CharField(max_length=255)
thumbnail = pw.CharField(max_length=255)
name = pw.CharField(max_length=255)
size = pw.IntegerField()
pokemons = []
for p in query:
p['pokemon_name'] = get_pokemon_name(p['pokemon_id'])
pokemons.append(p)
return pokemons
class Pokestop(BaseModel):
pokestop_id = CharField(primary_key=True)
enabled = BooleanField()
latitude = FloatField()
longitude = FloatField()
last_modified = DateTimeField()
lure_expiration = DateTimeField(null=True)
active_pokemon_id = IntegerField(null=True)
class Gym(BaseModel):
UNCONTESTED = 0
TEAM_MYSTIC = 1
TEAM_VALOR = 2
TEAM_INSTINCT = 3
gym_id = CharField(primary_key=True)
team_id = IntegerField()
guard_pokemon_id = IntegerField()
gym_points = IntegerField()
enabled = BooleanField()
latitude = FloatField()
longitude = FloatField()
last_modified = DateTimeField()