MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / fetch_prefs

Method fetch_prefs

web/setup.py:637–679  ·  view source on GitHub ↗

Get Preferences List.

(id: Optional[bool] = None, json: Optional[bool] = False)

Source from the content-addressed store, hash-verified

635 return ManagePreferences.fetch_prefs()
636
637 def fetch_prefs(id: Optional[bool] = None, json: Optional[bool] = False):
638 """Get Preferences List."""
639 app = create_app(config.APP_NAME + '-cli')
640 table = Table(title="Pref Details", box=box.ASCII)
641 table.add_column("Preference", style="green")
642 with app.app_context():
643 from pgadmin.model import Preferences as PrefTable, \
644 ModulePreference as ModulePrefTable, \
645 PreferenceCategory as PrefCategoryTbl
646
647 module_prefs = ModulePrefTable.query.all()
648 cat_prefs = PrefCategoryTbl.query.all()
649 prefs = PrefTable.query.all()
650 if id:
651 all_preferences = {}
652 else:
653 all_preferences = []
654 for i in module_prefs:
655 for j in cat_prefs:
656 if i.id == j.mid:
657 for k in prefs:
658 if k.cid == j.id:
659 if id:
660 all_preferences["{0}:{1}:{2}".format(
661 i.name, j.name, k.name)
662 ] = "{0}:{1}:{2}".format(i.id, j.id, k.id)
663 else:
664 table.add_row("{0}:{1}:{2}".format(
665 i.name, j.name, k.name))
666 all_preferences.append(
667 "{0}:{1}:{2}".format(
668 i.name, j.name, k.name)
669 )
670 if id:
671 return all_preferences
672 else:
673 if json:
674 json_formatted_str = jsonlib.dumps(
675 {"Preferences": all_preferences},
676 indent=0)
677 print(json_formatted_str)
678 else:
679 print(table)
680
681 @app.command()
682 @update_sqlite_path

Callers 2

get_prefsMethod · 0.80
set_prefsMethod · 0.80

Calls 3

create_appFunction · 0.90
appendMethod · 0.80
TableFunction · 0.50

Tested by

no test coverage detected