Skip to content

Commit

Permalink
LINT
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhadeepJasu committed Feb 8, 2025
1 parent e5e4478 commit 34c5f5a
Show file tree
Hide file tree
Showing 9 changed files with 384 additions and 362 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MESSAGES CONTROL]
disable=import-error
disable=import-error,too-few-public-methods
12 changes: 12 additions & 0 deletions data/com.github.subhadeepjasu.pebbles.desktop.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Desktop Entry]
Name=Pebbles
GenericName=Pebbles Calculator App
Comment=Perform advanced calculations with ease
Categories=Utility;Calculator;GTK;
Exec=com.github.subhadeepjasu.pebbles
Icon=com.github.subhadeepjasu.pebbles
Terminal=false
Type=Application
Keywords=calculator;scientific;programmer;statistics;converter;convert;calculate;boolean;
X-GNOME-Gettext-Domain=com.github.subhadeepjasu.pebbles
Actions=MiniMode;NewWindow;
10 changes: 10 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ install_data(
install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps')
)

# Translate and install our .desktop file so the Applications Menu will see it
i18n.merge_file (
input: meson.project_name () + '.desktop.in',
output: meson.project_name () + '.desktop',
po_dir: join_paths (meson.current_source_dir(), 'po', 'extra'),
type: 'desktop',
install: true,
install_dir: join_paths (get_option ('datadir'), 'applications')
)

# Install Settings schema
schemas_conf = configuration_data()
schemas_conf.set('SCHEMA_ID', application_id)
Expand Down
12 changes: 5 additions & 7 deletions src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ def __init__(self, application_id, **kwargs):
)
self.connect("create_window_request", self._on_create_window_request)

self.setup()
self._setup_style()


def setup(self):
import logging
from gettext import gettext as _

# settings = Gio.Settings(self.props.application_id)
# self.props.settings = settings
def _setup_style(self):
"""
Setup styling.
"""

# Set CSS provider
css_provider = Gtk.CssProvider()
Expand Down
38 changes: 33 additions & 5 deletions src/core/memory.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2024 Subhadeep Jasu <[email protected]>

"""
Contextual Memory Store
"""

class ContextualMemory:
"""Contextual memory for storing arbitrary values for user."""

def __init__(self):
self._memory = dict()
self._last_ans = dict()
self._memory = {}
self._last_ans = {}

for k in ["global", "sci", "calc", "prog", "stat", "conv"]:
self._memory[k] = 0
self._last_ans[k] = 0


def add(self, value: int | float | complex, context="global"):
"""
Add the entered value or result to the value in memory.
"""
self._memory[context] += value


def subtract(self, value: int | float | complex, context="global"):
"""
Subtract the entered value or result from the value in memory.
"""
self._memory[context] -= value


def recall(self, context="global"):
"""
Reveal the value in memory.
"""
value = self._memory[context]
if context not in ["sci", "calc"]:
if type(value) == complex:
if isinstance(value, complex):
value = float(value.imag)

if context == "prog":
Expand All @@ -33,22 +46,31 @@ def recall(self, context="global"):
return value

def clear(self, context="global"):
"""
Clear memory.
"""
value = self._memory[context]
self._memory[context] = 0
return value


def set_last_ans(self, value: float | complex, context="global"):
"""
Save the last answer in memory.
"""
self._last_ans[context] = value
if context != "global":
self._last_ans["global"] = value


def get_last_ans(self, context="global"):
"""
Fetch the last answer in memory.
"""
value = self._last_ans[context]

if context not in ["sci", "calc"]:
if type(value) == complex:
if isinstance(value, complex):
value = float(value.imag)

if context == "prog":
Expand All @@ -58,13 +80,19 @@ def get_last_ans(self, context="global"):


def peek(self):
"""
Print the memory data.
"""
print('Memory: ', self._memory)
print('Last Answer: ', self._last_ans)


def any(self, context='global') -> bool:
"""
Returns True is anything is present in memory for the given context.
"""
value = self._memory[context]
if type(value) == complex:
if isinstance(value, complex):
return value.imag != 0 or value.real != 0

return value != 0
Loading

0 comments on commit 34c5f5a

Please sign in to comment.