Skip to content

Commit

Permalink
Merge pull request #90 from t00m/0.1.0-rc1
Browse files Browse the repository at this point in the history
0.1.0 rc1
  • Loading branch information
t00m authored Aug 21, 2024
2 parents 0993b97 + ab8d385 commit 4174a1d
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 74 deletions.
37 changes: 31 additions & 6 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
### Added

### Changed
### Changed

### Deprecated
### Deprecated

### Removed
### Removed

### Fixed
### Fixed

### Security
### Security


## [0.1.0-rc1] - 2024-08-21

### First Release Candidate for version 0.1

### Added
- N/A

### Changed
- Reduce log level verbosity (from DEBUG to TRACE)

### Deprecated
- N/A

### Removed
- N/A

### Fixed

- Add missing icons for date and concept actionrows in Rename dialog
- Do not raise error when disabling an already disabled plugin

### Security
- N/A


## [0.0.99] - 2024-07-25
Expand Down
9 changes: 4 additions & 5 deletions MiAZ/backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def load(self, filepath: str) -> dict:
config_changed = True

if config_changed:
self.log.debug(f"Loading {self.config_for} items from disk ({filepath})")
self.log.trace(f"Loading {self.config_for} items from disk ({filepath})")
try:
items = util.json_load(filepath)
self.cache[filepath] = {}
self.cache[filepath]['changed'] = False
self.cache[filepath]['items'] = items
# ~ self.log.debug(f"In-memory config data updated for '{filepath}'")
self.log.trace(f"In-memory config data updated for '{filepath}'")
except Exception:
items = []
return items
Expand All @@ -101,11 +101,11 @@ def load(self, filepath: str) -> dict:
return self.cache[filepath]['items']

def load_available(self) -> dict:
# ~ self.log.debug(f"{self.config_for} available: {self.available}")
self.log.trace(f"{self.config_for} available: {self.available}")
return self.load(self.available)

def load_used(self) -> dict:
# ~ self.log.debug(f"{self.config_for} used: {self.used}")
self.log.trace(f"{self.config_for} used: {self.used}")
return self.load(self.used)

def save(self, filepath: str = '', items: dict = None) -> bool:
Expand Down Expand Up @@ -322,7 +322,6 @@ def __init__(self, app, dir_conf):
must_copy=False,
foreign=True
)
self.log.debug("Config for countries created")


class MiAZConfigGroups(MiAZConfig):
Expand Down
7 changes: 3 additions & 4 deletions MiAZ/backend/pluginsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, app):
self.log = MiAZLog('MiAZ.PluginManager')
self.app = app
self.util = self.app.get_service('util')
self.log.debug("Initializing Plugin Manager")
self.log.trace("Initializing Plugin Manager")
self.plugin_info_list = []

self.engine = Peas.Engine.get_default()
Expand Down Expand Up @@ -140,8 +140,7 @@ def load_plugin(self, plugin: Peas.PluginInfo) -> bool:
self.engine.load_plugin(plugin)

if plugin.is_loaded():

self.log.debug(f"Plugin {pname} v{pvers} ({ptype}) loaded")
self.log.info(f"Plugin {pname} v{pvers} ({ptype}) loaded")
return True
else:
self.log.error(f"Plugin {pname} v{pvers} ({ptype}) couldn't be loaded")
Expand All @@ -157,7 +156,7 @@ def unload_plugin(self, plugin: Peas.PluginInfo):
pname = plugin.get_name()
pvers = plugin.get_version()
self.engine.unload_plugin(plugin)
self.log.debug(f"Plugin {pname} v{pvers} ({ptype}) unloaded")
self.log.info(f"Plugin {pname} v{pvers} ({ptype}) unloaded")
except Exception as error:
self.log.error(error)

Expand Down
2 changes: 1 addition & 1 deletion MiAZ/backend/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def check(self):
to_delete.append((doc, project))
for doc, project in to_delete:
self.remove(project, doc)
self.log.debug("Projects consistency checked")
self.log.trace("Projects consistency checked")

def add(self, project: str, doc: str):
"""
Expand Down
4 changes: 2 additions & 2 deletions MiAZ/backend/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def validate(self, path: str) -> bool:
try:
conf_dir = os.path.join(path, '.conf')
conf_file = os.path.join(conf_dir, 'repo.json')
self.log.debug(f"Validating repository '{conf_file}'")
self.log.trace(f"Validating repository '{conf_file}'")
if os.path.exists(conf_dir):
if os.path.exists(conf_file):
with open(conf_file, 'r') as fin:
Expand All @@ -62,7 +62,7 @@ def validate(self, path: str) -> bool:
valid = True
except Exception as error:
self.log.error(error)
self.log.debug(f"Repository {conf_file} valid? {valid}")
self.log.trace(f"Repository {conf_file} valid? {valid}")
except Exception as warning:
self.log.warning(warning)
return valid
Expand Down
4 changes: 2 additions & 2 deletions MiAZ/backend/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def filename_date_human_simple(self, value: str = '') -> str:
return date_dsc

def filename_display(self, filepath):
self.log.debug(f"OS Platform: {sys.platform}")
# ~ self.log.debug(f"OS Platform: {sys.platform}")
if sys.platform in ['linux', 'linux2']:
os.system(f"xdg-open \"{filepath}\"")
elif sys.platform in ['win32', 'cygwin', 'msys']:
Expand Down Expand Up @@ -315,7 +315,7 @@ def string_to_datetime(self, adate: str) -> datetime:

def zip(self, filename: str, directory: str):
""" Zip directory into a file """
self.log.debug(f"Target: {filename}")
# ~ self.log.debug(f"Target: {filename}")
sourcename = os.path.basename(filename)
dot = sourcename.find('.')
if dot == -1:
Expand Down
4 changes: 2 additions & 2 deletions MiAZ/backend/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, dirpath: str = None):
GObject.signal_new('repository-updated', MiAZWatcher, GObject.SignalFlags.RUN_LAST, None, ())
self.set_path(dirpath)
GLib.timeout_add_seconds(1, self.watch)
self.log.debug("Watcher initialized")
self.log.trace("Watcher initialized")

# PLAIN
def __files_with_timestamp(self, rootdir):
Expand Down Expand Up @@ -65,7 +65,7 @@ def __files_with_timestamp(self, rootdir):
def set_path(self, dirpath: str):
if dirpath is not None:
self.dirpath = dirpath
self.log.debug(f"Watcher monitoring '{self.dirpath}'")
self.log.info(f"Watcher monitoring '{self.dirpath}'")

def set_active(self, active: bool = True) -> None:
self.active = active
Expand Down
16 changes: 8 additions & 8 deletions MiAZ/frontend/desktop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _setup_ui(self):
theme = self.set_service('theme', Gtk.IconTheme.get_for_display(window.get_display()))
theme.add_search_path(ENV['GPATH']['ICONS'])
theme.add_search_path(ENV['GPATH']['FLAGS'])
self.log.debug(f"MiAZ custom icons in: {ENV['GPATH']['ICONS']}")
self.log.trace(f"MiAZ custom icons in: {ENV['GPATH']['ICONS']}")

# Setup main window contents
mainbox = self.add_widget('window-mainbox', MiAZMainWindow(self))
Expand All @@ -133,7 +133,7 @@ def _setup_ui(self):
self.set_menubar(menubar)

def _on_window_close_request(self, *args):
self.log.debug("Close application requested")
self.log.trace("Close application requested")
actions = self.get_service('actions')
actions.exit_app()

Expand Down Expand Up @@ -162,7 +162,7 @@ def _load_plugins(self):
if ptype == MiAZPluginType.SYSTEM:
np += 1
self.plugins_loaded = True
self.log.debug(f"System plugins loaded: {ap}/{np}")
self.log.info(f"System plugins loaded: {ap}/{np}")

# Load User Plugins
self.log.debug("Loading user plugins for this repository...")
Expand All @@ -183,7 +183,7 @@ def _load_plugins(self):
self.log.error(error)
if ptype == MiAZPluginType.USER:
np += 1
self.log.debug(f"User plugins loaded for this repoitory: {ap}/{np}")
self.log.info(f"User plugins loaded for this repository: {ap}/{np}")

def get_config(self, name: str):
try:
Expand All @@ -194,7 +194,7 @@ def get_config(self, name: str):

def switch_start(self):
"""Switch from one repository to another."""
self.log.debug("Repository switch requested")
self.log.trace("Repository switch requested")
actions = self.get_service('actions')
repository = self.get_service('repo')
try:
Expand All @@ -208,10 +208,10 @@ def switch_start(self):
repo_loaded = False

repo_id = appconf.get('current')
self.log.debug(f"Repository '{repo_id}' loaded? {repo_loaded}")
self.log.trace(f"Repository '{repo_id}' loaded? {repo_loaded}")

if repo_loaded:
self.log.debug(f"Repo Working directory: '{repository.docs}")
self.log.info(f"Repo Working directory: '{repository.docs}'")
repo_settings = self.get_widget('settings-repo')
if repo_settings is None:
repo_settings = self.add_widget('settings-repo', MiAZRepoSettings(self))
Expand All @@ -237,7 +237,7 @@ def switch_finish(self, *args):
watcher.set_path(repository.docs)
watcher.set_active(active=True)
self.app.set_service('watcher', watcher)
self.log.debug("Repository switch finished")
self.log.trace("Repository switch finished")

# Setup stack pages
mainbox = self.get_widget('window-mainbox')
Expand Down
2 changes: 1 addition & 1 deletion MiAZ/frontend/desktop/services/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def toggle_workspace_filters(self, *args):
btnShowFilters.set_active(not active)

def exit_app(self, *args):
self.log.debug('Closing MiAZ')
self.log.trace('Closing MiAZ')
self.app.emit("exit-application")
self.app.quit()

Expand Down
32 changes: 20 additions & 12 deletions MiAZ/frontend/desktop/services/icm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
# License: GPL v3
# Description: Icon manager

import os

from gi.repository import Gtk
from gi.repository import Gio
from gi.repository import GObject

from MiAZ.backend.log import MiAZLog


class MiAZIconManager(GObject.GObject):
"""
Expand All @@ -26,6 +30,8 @@ def __init__(self, app):
:type app: MiAZApp
"""
super().__init__()
self.app = app
self.log = MiAZLog('MiAZ.IconManager')

def get_image_by_name(self, name: str, size: int = 24) -> Gtk.Image:
"""
Expand All @@ -42,18 +48,20 @@ def get_image_by_name(self, name: str, size: int = 24) -> Gtk.Image:
image.set_pixel_size(size)
return image

def get_mimetype_icon(self, mimetype: str) -> Gio.Icon:
def get_mimetype_icon(self, filename: str) -> Gio.Icon:
"""
Get icon for a given mimetype.
Get mimetype icon for a given file.
:param mimetype: file mimetype
:type mimetype: str
:return: an icon
:rtype: Gio.Icon
:param filename: file name
:type filename: str
return: an icon
rtype: Gio.ThemedIcon (GIcon)
"""
try:
gicon = self.gicondict[mimetype]
except KeyError:
gicon = Gio.content_type_get_icon(mimetype)
self.gicondict[mimetype] = gicon
return gicon
repository = self.app.get_service('repo')
basedir = repository.docs
filepath = os.path.join(basedir, filename)
if os.path.exists(filepath):
gfile = Gio.File.new_for_path(filepath)
info = gfile.query_info(Gio.FILE_ATTRIBUTE_STANDARD_ICON, Gio.FileQueryInfoFlags.NONE, None)
gicon = info.get_icon()
return gicon
21 changes: 13 additions & 8 deletions MiAZ/frontend/desktop/widgets/configview.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,21 @@ def _on_item_used_remove(self, *args):
plugin = plugin_manager.get_plugin_info(selected_plugin.id)
if plugin.is_loaded():
plugin_manager.unload_plugin(plugin)
self.log.debug(f"Plugin '{selected_plugin.id}' unloaded")
self.log.trace(f"Plugin '{selected_plugin.id}' unloaded")
except AttributeError as error:
self.log.error(f"Unknown error unloading plugin '{selected_plugin.id}'")
self.log.error(error)
finally:
del(plugins_used[selected_plugin.id])
self.log.debug(f"Plugin '{selected_plugin.id}' removed from used view")
self.config.save_used(items=plugins_used)
self._update_view_used()
try:
del(plugins_used[selected_plugin.id])
self.log.debug(f"Plugin '{selected_plugin.id}' deactivated")
self.config.save_used(items=plugins_used)
self._update_view_used()
except KeyError:
# FIXME: it shouldn't reach this code.
# It happens when the user removes a plugin from the
# used view and hit the button remove ([<]) again.
pass

def _on_item_used_add(self, *args):
plugin_manager = self.app.get_service('plugin-manager')
Expand All @@ -478,14 +484,13 @@ def _on_item_used_add(self, *args):
i_title = item_type.__title__
if not plugin_used:
plugins_used[selected_plugin.id] = selected_plugin.title
self.log.debug(f"Using {selected_plugin.id} ({selected_plugin.title})")
plugin = plugin_manager.get_plugin_info(selected_plugin.id)
if not plugin.is_loaded():
plugin_manager.load_plugin(plugin)
self.config.save_used(items=plugins_used)
self._update_view_used()
self.log.debug(f"{i_title} {selected_plugin.id} not used yet. Can be used now")
self.log.debug(f"{i_title} {selected_plugin.id} activated")
else:
self.log.debug(f"{i_title} {selected_plugin.id} is already being used")
self.log.debug(f"{i_title} '{selected_plugin.id}' was already activated. Nothing to do")


Loading

0 comments on commit 4174a1d

Please sign in to comment.