# Path: app.py
# def inject_static():
#     def static(filename, **kwargs):
# def install_security_headers(resp):
# 
# Path: libforget/interval.py
# def decompose_interval(attrname):
#     scales = [scale[1] for scale in SCALES]
#     scales.reverse()
# 
#     def decorator(cls):
#         scl_name = '{}_scale'.format(attrname)
#         sig_name = '{}_significand'.format(attrname)
# 
#         @property
#         def scale(self):
# 
#             if getattr(self, attrname) == timedelta(0):
#                 return timedelta(minutes=1)
# 
#             for m in scales:
#                 if getattr(self, attrname) % m == timedelta(0):
#                     return m
# 
#             return timedelta(minutes=1)
# 
#         @scale.setter
#         def scale(self, value):
#             if not isinstance(value, timedelta):
#                 value = timedelta(seconds=float(value))
#             setattr(self, attrname, max(1, getattr(self, sig_name)) * value)
# 
#         @property
#         def significand(self):
#             return int(getattr(self, attrname) / getattr(self, scl_name))
# 
#         @significand.setter
#         def significand(self, value):
#             if isinstance(value, str) and value.strip() == '':
#                 value = 0
# 
#             try:
#                 value = int(value)
#                 if not value >= 0:
#                     raise ValueError(value)
#             except ValueError as e:
#                 raise ValueError("Incorrect time interval", e)
#             setattr(self, attrname, value * getattr(self, scl_name))
# 
#         setattr(cls, scl_name, scale)
#         setattr(cls, sig_name, significand)
# 
#         return cls
# 
#     return decorator


from datetime import timedelta, datetime, timezone
from app import db
from libforget.interval import decompose_interval
from sqlalchemy.ext.declarative import declared_attr
        from app import imgproxy
        from flask import url_for
import secrets
import random
        self.id = "misskey:{}@{}".format(self.misskey_id, instance)
        
    @property
    def misskey_id(self):
        if not self.id:
            return None
        if self.service != "misskey":
            raise Exception(
                    "tried to get misskey id for a {} {}"
                    .format(self.service, type(self)))
        return self.id.split(":", 1)[1].split('@')[0]

    @misskey_id.setter
    def misskey_id(self, id_):
        self.id = "misskey:{}@{}".format(id_, self.misskey_instance)

    @property
    def remote_id(self):
        if self.service == 'twitter':
            return self.twitter_id
        elif self.service == 'mastodon':
            return self.mastodon_id
        elif self.service == 'misskey':
            return self.misskey_id


ThreeWayPolicyEnum = db.Enum('keeponly', 'deleteonly', 'none',
        name='enum_3way_policy')



# Path: app.py
# def inject_static():
#     def static(filename, **kwargs):
# def install_security_headers(resp):
# 
# Path: libforget/interval.py
# def decompose_interval(attrname):
#     scales = [scale[1] for scale in SCALES]
#     scales.reverse()
# 
#     def decorator(cls):
#         scl_name = '{}_scale'.format(attrname)
#         sig_name = '{}_significand'.format(attrname)
# 
#         @property
#         def scale(self):
# 
#             if getattr(self, attrname) == timedelta(0):
#                 return timedelta(minutes=1)
# 
#             for m in scales:
#                 if getattr(self, attrname) % m == timedelta(0):
#                     return m
# 
#             return timedelta(minutes=1)
# 
#         @scale.setter
#         def scale(self, value):
#             if not isinstance(value, timedelta):
#                 value = timedelta(seconds=float(value))
#             setattr(self, attrname, max(1, getattr(self, sig_name)) * value)
# 
#         @property
#         def significand(self):
#             return int(getattr(self, attrname) / getattr(self, scl_name))
# 
#         @significand.setter
#         def significand(self, value):
#             if isinstance(value, str) and value.strip() == '':
#                 value = 0
# 
#             try:
#                 value = int(value)
#                 if not value >= 0:
#                     raise ValueError(value)
#             except ValueError as e:
#                 raise ValueError("Incorrect time interval", e)
#             setattr(self, attrname, value * getattr(self, scl_name))
# 
#         setattr(cls, scl_name, scale)
#         setattr(cls, sig_name, significand)
# 
#         return cls
# 
#     return decorator


# Path: model.py
from datetime import timedelta, datetime, timezone
from app import db
from libforget.interval import decompose_interval
from sqlalchemy.ext.declarative import declared_attr
        from app import imgproxy
        from flask import url_for
import secrets
import random

        self.id = "misskey:{}@{}".format(self.misskey_id, instance)
        
    @property
    def misskey_id(self):
        if not self.id:
            return None
        if self.service != "misskey":
            raise Exception(
                    "tried to get misskey id for a {} {}"
                    .format(self.service, type(self)))
        return self.id.split(":", 1)[1].split('@')[0]

    @misskey_id.setter
    def misskey_id(self, id_):
        self.id = "misskey:{}@{}".format(id_, self.misskey_instance)

    @property
    def remote_id(self):
        if self.service == 'twitter':
            return self.twitter_id
        elif self.service == 'mastodon':
            return self.mastodon_id
        elif self.service == 'misskey':
            return self.misskey_id


ThreeWayPolicyEnum = db.Enum('keeponly', 'deleteonly', 'none',
        name='enum_3way_policy')



@decompose_interval('policy_delete_every')