Skip to content

Commit

Permalink
Rename ctrl classes to PascalCase
Browse files Browse the repository at this point in the history
Patterns: TypeControlCommon, TypeControlCommandline
  • Loading branch information
JOJ0 committed Nov 2, 2024
1 parent 118ce43 commit 88b341b
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 47 deletions.
18 changes: 9 additions & 9 deletions discodos/cmd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from discodos.utils import print_help # , ask user
from discodos.args_helper import User_int
from discodos.ctrls import Mix_ctrl_cli, Coll_ctrl_cli
from discodos.ctrls import MixControlCommandline, CollectionControlCommandline
from discodos.config import Db_setup, Config
import logging
import argparse
Expand Down Expand Up @@ -411,7 +411,7 @@ def _main():
user = User_int(args)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
# INIT COLLECTION CONTROLLER (DISCOGS API CONNECTION) ######################
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user,
conf.discogs_token, conf.discogs_appid, conf.discobase,
conf.musicbrainz_user, conf.musicbrainz_password
Expand All @@ -436,7 +436,7 @@ def _main():
if coll_ctrl.ONLINE:
discogs_rel_found = coll_ctrl.search_release(searchterm)
if user.WANTS_TO_ADD_TO_MIX or user.WANTS_TO_ADD_AT_POSITION:
mix_ctrl = Mix_ctrl_cli(
mix_ctrl = MixControlCommandline(
False, args.add_to_mix, user, conf.discobase
)
mix_ctrl.add_discogs_track(
Expand Down Expand Up @@ -472,7 +472,7 @@ def _main():
if not database_rel_found:
return
if user.WANTS_TO_ADD_TO_MIX or user.WANTS_TO_ADD_AT_POSITION:
mix_ctrl = Mix_ctrl_cli(
mix_ctrl = MixControlCommandline(
False, args.add_to_mix, user, conf.discobase
)
mix_ctrl.add_offline_track(
Expand All @@ -494,7 +494,7 @@ def _main():
### NO MIX ID GIVEN ########################################################
if user.WANTS_TO_SHOW_MIX_OVERVIEW:
# we instantiate a mix controller object
mix_ctrl = Mix_ctrl_cli(False, args.mix_name, user, conf.discobase)
mix_ctrl = MixControlCommandline(False, args.mix_name, user, conf.discobase)
if user.WANTS_TO_PULL_TRACK_INFO_IN_MIX_MODE:
mix_ctrl.pull_track_info_from_discogs(
coll_ctrl,
Expand All @@ -512,11 +512,11 @@ def _main():
### MIX ID GIVEN ###########################################################
### SHOW MIX DETAILS #######################################################
elif user.WANTS_TO_SHOW_MIX_TRACKLIST:
log.info("A mix_name or ID was given. Instantiating Mix_ctrl_cli class.\n")
mix_ctrl = Mix_ctrl_cli(
log.info("A mix_name or ID was given. Instantiating MixControlCommandline class.\n")
mix_ctrl = MixControlCommandline(
False, args.mix_name, user, conf.discobase
)
# coll_ctrl = Coll_ctrl_cli(conn, user)
# coll_ctrl = CollectionControlCommandline(conn, user)
### CREATE A NEW MIX ###################################################
if user.WANTS_TO_CREATE_MIX:
mix_ctrl.create()
Expand Down Expand Up @@ -628,7 +628,7 @@ def _main():

##### STATS MODE ###########################################################
if user.WANTS_TO_SHOW_STATS:
# mix_ctrl = Mix_ctrl_cli(False, args.mix_name, user, conf.discobase)
# mix_ctrl = MixControlCommandline(False, args.mix_name, user, conf.discobase)
coll_ctrl.view_stats()

##### SETUP MODE ###########################################################
Expand Down
10 changes: 5 additions & 5 deletions discodos/cmd23/import_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import click
from click_option_group import optgroup, MutuallyExclusiveOptionGroup

from discodos.ctrl import Coll_ctrl_cli
from discodos.ctrl import CollectionControlCommandline

log = logging.getLogger('discodos')

Expand Down Expand Up @@ -52,7 +52,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down Expand Up @@ -137,7 +137,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down Expand Up @@ -191,7 +191,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand All @@ -214,7 +214,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down
4 changes: 2 additions & 2 deletions discodos/cmd23/ls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import click
from discodos.ctrl import Coll_ctrl_cli
from discodos.ctrl import CollectionControlCommandline

log = logging.getLogger('discodos')

Expand All @@ -27,7 +27,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down
12 changes: 6 additions & 6 deletions discodos/cmd23/mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import click
from click_option_group import MutuallyExclusiveOptionGroup, optgroup

from discodos.ctrl import Coll_ctrl_cli, Mix_ctrl_cli
from discodos.ctrl import CollectionControlCommandline, MixControlCommandline

log = logging.getLogger('discodos')

Expand Down Expand Up @@ -215,15 +215,15 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)

# NO MIX ID GIVEN #########################################################
# SHOW LIST OF MIXES ######################################################
if user.WANTS_TO_SHOW_MIX_OVERVIEW:
mix_ctrl = Mix_ctrl_cli(False, mix_name, user, user.conf.discobase)
mix_ctrl = MixControlCommandline(False, mix_name, user, user.conf.discobase)
if user.WANTS_TO_PULL_TRACK_INFO_IN_MIX_MODE:
mix_ctrl.pull_track_info_from_discogs(
coll_ctrl,
Expand All @@ -241,11 +241,11 @@ def update_user_interaction_helper(user):
# MIX ID GIVEN ############################################################
# SHOW MIX DETAILS ########################################################
elif user.WANTS_TO_SHOW_MIX_TRACKLIST:
log.info("A mix_name or ID was given. Instantiating Mix_ctrl_cli class.\n")
mix_ctrl = Mix_ctrl_cli(
log.info("A mix_name or ID was given. Instantiating MixControlCommandline class.\n")
mix_ctrl = MixControlCommandline(
False, mix_name, user, user.conf.discobase
)
# coll_ctrl = Coll_ctrl_cli(conn, user)
# coll_ctrl = CollectionControlCommandline(conn, user)
# CREATE A NEW MIX ####################################################
if user.WANTS_TO_CREATE_MIX:
mix_ctrl.create()
Expand Down
8 changes: 4 additions & 4 deletions discodos/cmd23/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import click
from click_option_group import optgroup, MutuallyExclusiveOptionGroup

from discodos.ctrl import Coll_ctrl_cli, Mix_ctrl_cli
from discodos.ctrl import CollectionControlCommandline, MixControlCommandline

log = logging.getLogger('discodos')

Expand Down Expand Up @@ -131,7 +131,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand All @@ -155,7 +155,7 @@ def update_user_interaction_helper(user):
if coll_ctrl.ONLINE:
discogs_rel_found = coll_ctrl.search_release(searchterm)
if user.WANTS_TO_ADD_TO_MIX or user.WANTS_TO_ADD_AT_POSITION:
mix_ctrl = Mix_ctrl_cli(
mix_ctrl = MixControlCommandline(
False, add_to_mix, user, user.conf.discobase
)
mix_ctrl.add_discogs_track(
Expand Down Expand Up @@ -191,7 +191,7 @@ def update_user_interaction_helper(user):
if not database_rel_found:
return
if user.WANTS_TO_ADD_TO_MIX or user.WANTS_TO_ADD_AT_POSITION:
mix_ctrl = Mix_ctrl_cli(
mix_ctrl = MixControlCommandline(
False, add_to_mix, user, user.conf.discobase
)
mix_ctrl.add_offline_track(
Expand Down
4 changes: 2 additions & 2 deletions discodos/cmd23/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import click

from discodos.config import Db_setup
from discodos.ctrl import Coll_ctrl_cli
from discodos.ctrl import CollectionControlCommandline

log = logging.getLogger('discodos')

Expand All @@ -24,7 +24,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down
4 changes: 2 additions & 2 deletions discodos/cmd23/stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import click

from discodos.ctrl import Coll_ctrl_cli
from discodos.ctrl import CollectionControlCommandline

log = logging.getLogger('discodos')

Expand All @@ -23,7 +23,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down
4 changes: 2 additions & 2 deletions discodos/cmd23/suggest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import click

from discodos.ctrl import Coll_ctrl_cli
from discodos.ctrl import CollectionControlCommandline

log = logging.getLogger('discodos')

Expand Down Expand Up @@ -58,7 +58,7 @@ def update_user_interaction_helper(user):

user = update_user_interaction_helper(helper)
log.info("user.WANTS_ONLINE: %s", user.WANTS_ONLINE)
coll_ctrl = Coll_ctrl_cli(
coll_ctrl = CollectionControlCommandline(
False, user, user.conf.discogs_token, user.conf.discogs_appid,
user.conf.discobase, user.conf.musicbrainz_user,
user.conf.musicbrainz_password)
Expand Down
8 changes: 4 additions & 4 deletions discodos/ctrl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from discodos.ctrl.collection import Coll_ctrl_cli
from discodos.ctrl.mix import Mix_ctrl_cli
from discodos.ctrl.collection import CollectionControlCommandline
from discodos.ctrl.mix import MixControlCommandline

__ALL__ = [
Coll_ctrl_cli,
Mix_ctrl_cli
CollectionControlCommandline,
MixControlCommandline
]
10 changes: 4 additions & 6 deletions discodos/ctrl/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import discogs_client.exceptions as errors

from discodos.ctrl.common import Ctrl_common
from discodos.ctrl.common import ControlCommon
from discodos.model_brainz import Brainz
from discodos.model_brainz_match import Brainz_match
from discodos.model_collection import Collection
Expand All @@ -15,15 +15,13 @@
log = logging.getLogger('discodos')


# Collection controller common methods
class Coll_ctrl_common (ABC):
class CollectionControlCommon (ABC):
"""Common controller functionality for the Discogs user profile"""
def __init__(self):
pass


# Collection controller class
class Coll_ctrl_cli (Ctrl_common, Coll_ctrl_common):
class CollectionControlCommandline (ControlCommon, CollectionControlCommon):
"""CLI level controller functionality, offline & Discogs user profile"""

def __init__(self, _db_conn, _user_int, _userToken, _appIdentifier,
Expand All @@ -33,7 +31,7 @@ def __init__(self, _db_conn, _user_int, _userToken, _appIdentifier,
self.collection = Collection(_db_conn, _db_file)
if self.collection.db_not_found is True:
self.cli.ask('Setting up DiscoBASE, press enter...')
super(Coll_ctrl_cli, self).setup_db(_db_file)
super(CollectionControlCommandline, self).setup_db(_db_file)
self.collection = Collection(_db_conn, _db_file)
if self.user.WANTS_ONLINE:
if not self.collection.discogs_connect(_userToken, _appIdentifier):
Expand Down
2 changes: 1 addition & 1 deletion discodos/ctrl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
log = logging.getLogger('discodos')


class Ctrl_common (ABC):
class ControlCommon (ABC):
"""Common controller functionality"""
def setup_db(self, db_file):
"""Manages database initialization and schema upgrades"""
Expand Down
8 changes: 4 additions & 4 deletions discodos/ctrl/mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from abc import ABC
# import pprint as p

from discodos.ctrl.common import Ctrl_common
from discodos.ctrl.common import ControlCommon
from discodos.model_mix import Mix
from discodos.utils import is_number
from discodos.view_cli import Mix_view_cli
Expand All @@ -11,14 +11,14 @@


# mix controller class (abstract) - common attrs and methods for gui and cli
class Mix_ctrl_common (ABC):
class MixControlCommon (ABC):
"""Common controller functionality for mixes"""
def __init__(self):
pass


# mix controller class CLI implementation
class Mix_ctrl_cli (Ctrl_common, Mix_ctrl_common):
class MixControlCommandline (ControlCommon, MixControlCommon):
"""Controls CLI logic for mixes """

def __init__(self, db_conn, mix_name_or_id, _user_int, db_file = False):
Expand All @@ -27,7 +27,7 @@ def __init__(self, db_conn, mix_name_or_id, _user_int, db_file = False):
self.mix = Mix(db_conn, mix_name_or_id, db_file) # instantiate the Mix model class
if self.mix.db_not_found == True:
self.cli.ask('Setting up DiscoBASE, press enter...')
super(Mix_ctrl_cli, self).setup_db(db_file)
super(MixControlCommandline, self).setup_db(db_file)
self.mix = Mix(db_conn, db_file)

def create(self):
Expand Down

0 comments on commit 88b341b

Please sign in to comment.