Ejemplo n.º 1
0
 def delete(self, idx: int):
     col = self.get_one(idx)
     if col:
         col.update(active=False)
         if col.save():
             print_lib('Deleted manga <%d>' % idx, file=stderr)
     else:
         print_lib('Id <%d> not found' % idx, file=stderr)
Ejemplo n.º 2
0
 def enable(self, idx: int):
     col = self.get_one(idx)
     if col:
         col.update(active=True)
         if col.save():
             print_lib('Enabled manga <%d>' % idx, file=stderr)
     else:
         print_lib('Id <%d> not found' % idx, file=stderr)
Ejemplo n.º 3
0
 def print_all(self, _filter: str):
     headers = ['id', 'name', 'active', 'path', 'created', 'updated']
     data = []
     for col in self.get_all():
         data.append([
             col.id,
             col.name,
             col.active,
             col.path,
             col.created,
             col.updated,
         ])
     if len(data) > 0:
         print_lib(tabulate(data, headers))
     else:
         print_lib('Database is empty')
Ejemplo n.º 4
0
 def print_from_idx(self, *idx: int):
     data = []
     headers = ['id', 'name', 'active', 'path', 'created', 'updated']
     for _idx in idx:
         col = self.get_one(_idx)
         if col:
             data.append([
                 col.id,
                 col.name,
                 col.active,
                 col.path,
                 col.created,
                 col.updated,
             ])
     if len(data) > 0:
         print_lib(tabulate(data, headers))
     else:
         print_lib('Database is empty')
Ejemplo n.º 5
0
 def clean(self):
     make_db(force=True)
     print_lib('Database clean now!', file=stderr)
Ejemplo n.º 6
0
 def print_error(cls, *_args):
     print_lib(*_args, file=stderr)