Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Advanced Emulator Launcher main script file
#

# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
# Portions (c) 2018 Chrisism
# Portions (c) 2010-2015 Angelscry and others
#
Expand Down
1 change: 1 addition & 0 deletions resources/lib/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
import resources.lib.commands.stats_commands
import resources.lib.commands.misc_commands
import resources.lib.commands.chk_commands
import resources.lib.commands.report_commands
2 changes: 1 addition & 1 deletion resources/lib/commands/addon_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (import & export of configurations)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/category_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (category management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/chk_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (check data)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (miscellaneous)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
72 changes: 72 additions & 0 deletions resources/lib/commands/report_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
#
# Advanced Emulator Launcher: Commands (reporting)
#
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# --- Python standard library ---
from __future__ import unicode_literals
from __future__ import division

import logging

from ael.utils import kodi, text

from resources.lib.commands.mediator import AppMediator

from resources.lib.repositories import CategoryRepository, ROMCollectionRepository, UnitOfWork
from resources.lib import globals

logger = logging.getLogger(__name__)

@AppMediator.register('GLOBAL_ROM_STATS')
def cmd_report_global_rom_stats(args):
window_title = 'Global ROM statistics'
sl = []
# sl.append('[COLOR violet]Launcher ROM report.[/COLOR]')
# sl.append('')

# --- Table header ---
table_str = [
['left', 'left', 'left'],
['Category', 'Collection', 'ROMs'],
]

uow = UnitOfWork(globals.g_PATHS.DATABASE_FILE_PATH)
with uow:
category_repository = CategoryRepository(uow)
romcollections_repository = ROMCollectionRepository(uow)

categories = [*category_repository.find_all_categories()]
collection_count = romcollections_repository.count_collections()

# Traverse categories and sort alphabetically.
logger.debug(f'Number of categories {len(categories)}')
logger.debug(f'Number of collections {collection_count}')

for category in categories:
# Get collection of this category alphabetically sorted.
collections_by_category = romcollections_repository.find_romcollections_by_parent(category.get_id())
# Render list of launchers for this category.
for collection in collections_by_category:
table_str.append([category.get_name(), collection.get_name(), str(collection.num_roms())])

# Traverse categoryless launchers.
root_collections = romcollections_repository.find_root_romcollections()
for collection in root_collections:
table_str.append(['', collection.get_name(), str(collection.num_roms())])

# Generate table and print report
# logger.debug(unicode(table_str))
sl.extend(text.render_table_str(table_str))
kodi.display_text_window_mono(window_title, '\n'.join(sl))
2 changes: 1 addition & 1 deletion resources/lib/commands/rom_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (ROM management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/rom_launcher_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (romcollection launcher management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/rom_scanner_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (romcollection scanner management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/rom_scraper_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (ROM scraper management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/romcollection_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (romcollection management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/romcollection_roms_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (romcollection roms management)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/stats_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (generating stats and counts)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/commands/view_rendering_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher: Commands (Precompiling the view data)
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Advanced Emulator Launcher miscellaneous set of objects
#
# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Advanced Emulator Launcher: metadata editor actions
#

# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
# Portions (c) 2010-2015 Angelscry
#
# This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Advanced Emulator Launcher: Globals
#

# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
# Portions (c) 2010-2015 Angelscry
#
# This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Advanced Emulator Launcher platform and emulator information
#

# Copyright (c) 2016-2018 Wintermute0110 <wintermute0110@gmail.com>
# Copyright (c) Wintermute0110 <wintermute0110@gmail.com> / Chrisism <crizizz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
7 changes: 7 additions & 0 deletions resources/lib/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def _update_asset(self, asset: Asset, category_obj: Category):
#
# ROMCollectionRepository -> ROM Sets from SQLite DB
#
QUERY_COUNT_ROMCOLLECTIONS = "SELECT COUNT(*) as count FROM vw_romcollections"
QUERY_SELECT_ROMCOLLECTION = "SELECT * FROM vw_romcollections WHERE id = ?"
QUERY_SELECT_ROMCOLLECTIONS = "SELECT * FROM vw_romcollections ORDER BY m_name"
QUERY_SELECT_ROOT_ROMCOLLECTIONS = "SELECT * FROM vw_romcollections WHERE parent_id IS NULL ORDER BY m_name"
Expand Down Expand Up @@ -650,6 +651,12 @@ class ROMCollectionRepository(object):
def __init__(self, uow: UnitOfWork):
self._uow = uow

def count_collections(self) -> int:
self._uow.execute(QUERY_COUNT_ROMCOLLECTIONS)
count_data = self._uow.single_result()

return int(count_data['count'])

def find_romcollection(self, romcollection_id: str) -> ROMCollection:
self._uow.execute(QUERY_SELECT_ROMCOLLECTION, romcollection_id)
romcollection_data = self._uow.single_result()
Expand Down
Loading