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)
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
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
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
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
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
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
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
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)
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()
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)
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)
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)
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)
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))
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))
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)
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)
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'), ))
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)
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))
class RawImportOptions(PropertySet): entry_id = Property(int) source_path = Property() folder = Property() mime_type = Property()
class TransferOptions(PropertySet): entry_id = Property() source_url = Property() source_root_path = Property() destination = Property() steps = Property(type=list)
class ToCutResult(PropertySet): path = Property()
class RawFetchOptions(PropertySet): entry_id = Property(int)
class ToCutOptions(PropertySet): source_root_path = Property() source_url = Property()
class ReadMetadataResult(PropertySet): metadata = Property(wrap=True)
class ReadMetadataOptions(PropertySet): path = Property() mime_type = Property() entry_id = Property()
class CalculateHashResult(PropertySet): calculated_hash = Property()
class CalculateHashOptions(PropertySet): path = Property()