Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
class Storage: def __init__(self): self.categories = [] self.topics = [] self.documents = [] def add_category(self, category: Category): if category in self.categories: return self.categories.append(category) def add_topic(self, topic:Topic): if topic in self.topics: return self.topics.append(topic) def add_document(self, document: Document): if document in self.documents: return self.documents.append(document) def edit_category(self, category_id, new_name): category = self.__find_my_id(self.categories, category_id) category.edit(new_name) def edit_topic(self, topic_id: int, new_topic: str, new_storage_folder: str): topic = self.__find_my_id(self.topics, topic_id) topic.edit(new_topic, new_storage_folder) def edit_document(self, document_id: int, new_file_name: str): document = self.__find_my_id(self.documents, document_id) document.edit(new_file_name) def delete_category(self, category_id): category = self.__find_my_id(self.categories, category_id) self.categories.remove(category) def delete_topic(self, topic_id): topic = self.__find_my_id(self.topics, topic_id) self.topics.remove(topic) def delete_document(self, document_id): document = self.__find_my_id(self.documents, document_id) self.topics.remove(document) def get_document(self, ): return self.__find_my_id(self.document, document_id) def __repr__(self): return "\n".join([repr(x) for x in self.documents]) def __find_my_id(self, entities, entity_id): for entity in entities: if entity.id = entity_id: return entity
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)