Пример #1
0
class File(PropertySet):
    reference = Property()
    revision = Property(int, name='_rev')
    url = Property(name='_id')
    mime_type = Property()
    status = Property(enum=FileStatus)

    @property
    def parsed_url(self):
        return urlparse(self.url)
Пример #2
0
class JobConfig(PropertySet):
    name = Property()
    settings = Property(wrap=True)

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.name = query.netloc
        inst.settings = get_schema(get_schema_name(inst.name))()
        for key, value in parse_qsl(query.query):
            setattr(inst.settings, key, value)
        return inst
Пример #3
0
class SystemConfig(PropertySet):
    name = Property()
    full_name = Property()

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.name = query.netloc
        for key, value in parse_qsl(query.query):
            if key == 'mount_root': value = get_path(value)
            setattr(inst, key, value)
        return inst
Пример #4
0
class DatabaseConfig(PropertySet):
    server = Property()
    path = Property()

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.server = query.netloc
        inst.path = get_path(query.path)
        for key, value in parse_qsl(query.query):
            setattr(inst, key, value)
        return inst
Пример #5
0
class ServerConfig(PropertySet):
    hostname = Property()
    mount_root = Property()
    workers = Property(int)

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.hostname = query.netloc
        for key, value in parse_qsl(query.query):
            setattr(inst, key, value)
        return inst
Пример #6
0
class ZeroMQConfig(PropertySet):
    server = Property()
    interface = Property(default='localhost')
    port = Property(int, default=5555)

    @classmethod
    def FromUrl(cls, query):
        print(query)
        inst = cls()
        inst.server = query.netloc
        for key, value in parse_qsl(query.query):
            setattr(inst, key, value)
        return inst
Пример #7
0
class HttpConfig(PropertySet):
    server = Property()
    interface = Property(default='localhost')
    port = Property(int, default=8080)
    adapter = Property(default='cheroot')
    debug = Property(bool, default=False)

    @classmethod
    def FromUrl(cls, query):
        print(query)
        inst = cls()
        inst.server = query.netloc
        for key, value in parse_qsl(query.query):
            setattr(inst, key, value)
        return inst
Пример #8
0
class ExportConfig(PropertySet):
    server = Property()
    path = Property()
    name = Property()
    filename = Property()
    longest_sise = Property(int)

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.server = query.netloc
        inst.path = get_path(query.path)
        for key, value in parse_qsl(query.query):
            setattr(inst, key, value)
        return inst
Пример #9
0
class DefaultEntryMetadata(PropertySet):
    title = Property()
    description = Property()
    author = Property()
    copyright = Property()
    source = Property()
    original_filename = Property()
    taken_ts = Property()
    orientation = Property()
    mirror = Property()
    angle = Property(int, default=0)

    def merge(self, other):
        for k, v in other.to_dict().items():
            if hasattr(self, k):
                setattr(self, k, v)
Пример #10
0
class JPEGExportOptions(PropertySet):
    entry_id = Property(int)
    entry_ids = Property(list)
    purpose = Property(enum=Purpose)
    version = Property(int)
    date = Property()
    longest_side = Property(int)
    folder = Property()
    filename = Property()
Пример #11
0
class DateStats(PropertySet):
    new = Property(int, none=0)
    pending = Property(int, none=0)
    keep = Property(int, none=0)
    purge = Property(int, none=0)
    todo = Property(int, none=0)
    wip = Property(int, none=0)
    final = Property(int, none=0)
    total = Property(int, none=0)
Пример #12
0
class JPEGImportOptions(PropertySet):
    entry_id = Property(int)
    source_path = Property()
    folder = Property()
    mime_type = Property()
    analyse = Property(bool)
    is_derivative = Property(bool, default=False)
    source_purpose = Property(enum=Purpose, default=Purpose.raw)
    source_version = Property(int)
Пример #13
0
class EntryQuery(Query):
    prev_offset = Property(int)
    offset = Property(int, default=0)
    page_size = Property(int, default=25, required=True)
    date = Property()
    state = Property(enum=State)
    delta = Property(int, default=0)
    reverse = Property(bool, default=False)
Пример #14
0
class FlickrOptions(PropertySet):
    entry_id = Property(int)
    source_purpose = Property(enum=Purpose, default=Purpose.original)
    source_version = Property(int)
    title = Property()
    description = Property()
    tags = Property(list)
    is_public = Property(bool, default=True)
Пример #15
0
class CardConfig(PropertySet):
    name = Property()
    mode = Property(enum=ImportMode)
    remove_source = Property(bool)
    extension = Property(list)

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.name = query.netloc
        for key, value in parse_qsl(query.query):
            if key == 'extension': value = value.split()
            setattr(inst, key, value)
        return inst

    def get_part_url(self, part):
        return self.get_path_url(part.path)

    def get_path_url(self, path):
        return urlunparse(('card', self.name, path, None, None, None))
Пример #16
0
class StorageConfig(PropertySet):
    server = Property()
    root_path = Property()
    type = Property(enum=StorageType)

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.server = query.netloc
        inst.root_path = resolve_path(get_path(query.path))
        for key, value in parse_qsl(query.query):
            setattr(inst, key, value)
        return inst

    def get_file_url(self, absolute_path):
        logging.info('RELPATH %s %s', absolute_path,
                     os.path.abspath(self.root_path))
        return urlunparse(('local', self.server,
                           os.path.relpath(absolute_path,
                                           os.path.abspath(self.root_path)),
                           None, None, None))
Пример #17
0
class EntryFeed(PropertySet):
    count = Property(int)
    total_count = Property(int)
    offset = Property(int)
    date = Property()
    state = Property(enum=State)
    entries = Property(Entry, is_list=True)
Пример #18
0
class Job(PropertySet):
    current_step = Property(type=int, default=0)
    steps = Property(type=Step, is_list=True)
    status = Property(enum=JobStatus, default=JobStatus.new)

    def get_current_step(self) -> Step:
        return self.steps[self.current_step]

    def get_on_with_it(self):
        step = self.get_current_step()
        if step.status != StepStatus.done:
            self.status = JobStatus.failed
            step.status = StepStatus.failed
        else:
            self.current_step += 1
            if self.current_step < len(self.steps):
                self.status = JobStatus.running
            else:
                self.status = JobStatus.done

    def get_step(self, method) -> Step:
        return next(filter(lambda x: x.method == method, self.steps), None)
Пример #19
0
class DateQuery(PropertySet):
    year = Property(int)
    month = Property(int)
    reverse = Property(bool, default=False)

    @classmethod
    def FromRequest(self):
        q = DateQuery()

        if bottle.request.query.year not in (None, ''):
            q.year = bottle.request.query.year
        if bottle.request.query.month not in (None, ''):
            q.month = bottle.request.query.month
        if bottle.request.query.reverse not in (None, ''):
            q.reverse = (bottle.request.query.reverse == 'yes')

        return q

    def to_query_string(self):
        return urllib.parse.urlencode((
            ('year', str(self.year) or ''),
            ('month', str(self.month) or ''),
            ('reverse', 'yes' if self.reverse else 'no'),
        ))
Пример #20
0
class RegisterPart(PropertySet):
    server = Property()
    source = Property()
    root_path = Property()
    path = Property()
    is_raw = Property(bool)
    mime_type = Property()

    def get_url(self, system):
        source = system.config.get_source_by_name(self.source)
        assert source is not None, "Source with name %s not found" % self.source
        return source.get_part_url(self)
Пример #21
0
class DropConfig(PropertySet):
    name = Property()
    server = Property()
    path = Property()
    mode = Property(enum=ImportMode)
    remove_source = Property(bool)
    extension = Property(list)

    @classmethod
    def FromUrl(cls, query):
        inst = cls()
        inst.server = query.netloc
        inst.path = get_path(query.path)
        for key, value in parse_qsl(query.query):
            if key == 'extension': value = value.split()
            setattr(inst, key, value)
        return inst

    def get_part_url(self, part):
        return urlunparse(
            ('local', self.server, os.path.join(self.path,
                                                part.path), None, None, None))
Пример #22
0
class RawImportOptions(PropertySet):
    entry_id = Property(int)
    source_path = Property()
    folder = Property()
    mime_type = Property()
Пример #23
0
class TransferOptions(PropertySet):
    entry_id = Property()
    source_url = Property()
    source_root_path = Property()
    destination = Property()
    steps = Property(type=list)
Пример #24
0
class ToCutResult(PropertySet):
    path = Property()
Пример #25
0
class RawFetchOptions(PropertySet):
    entry_id = Property(int)
Пример #26
0
class ToCutOptions(PropertySet):
    source_root_path = Property()
    source_url = Property()
Пример #27
0
class ReadMetadataResult(PropertySet):
    metadata = Property(wrap=True)
Пример #28
0
class ReadMetadataOptions(PropertySet):
    path = Property()
    mime_type = Property()
    entry_id = Property()
Пример #29
0
class CalculateHashResult(PropertySet):
    calculated_hash = Property()
Пример #30
0
class CalculateHashOptions(PropertySet):
    path = Property()