src/eric7/Preferences/ConfigurationPages/PipPage.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8981
fa03fe1fd672
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Package implementing the pip configuration page.
8 """
9
10 from .ConfigurationPageBase import ConfigurationPageBase
11 from .Ui_PipPage import Ui_PipPage
12
13 from PipInterface.Pip import Pip
14
15 import Preferences
16
17
18 class PipPage(ConfigurationPageBase, Ui_PipPage):
19 """
20 Class implementing the pip configuration page.
21 """
22 def __init__(self):
23 """
24 Constructor
25 """
26 super().__init__()
27 self.setupUi(self)
28 self.setObjectName("PipPage")
29
30 self.indexLabel.setText(self.tr(
31 '<b>Note:</b> Leave empty to use the default index URL ('
32 '<a href="{0}">{0}</a>).'
33 ).format(Pip.DefaultPyPiUrl))
34 self.safetyDbMirrorLabel.setText(self.tr(
35 '<b>Note:</b> Leave empty to use the default Safety DB URL ({0}).'
36 ).format(Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"]))
37
38 # set initial values
39 self.indexEdit.setText(Preferences.getPip("PipSearchIndex"))
40
41 safetyDbUrl = Preferences.getPip("VulnerabilityDbMirror")
42 if (
43 safetyDbUrl ==
44 Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"]
45 ):
46 safetyDbUrl = ""
47 self.safetyDbMirrorEdit.setText(safetyDbUrl)
48 self.validitySpinBox.setValue(
49 Preferences.getPip("VulnerabilityDbCacheValidity") // 3600)
50 # seconds converted to hours
51
52 self.noCondaCheckBox.setChecked(
53 Preferences.getPip("ExcludeCondaEnvironments"))
54
55 def save(self):
56 """
57 Public slot to save the pip configuration.
58 """
59 safetyDbUrl = self.safetyDbMirrorEdit.text().strip()
60 if not safetyDbUrl:
61 safetyDbUrl = Preferences.Prefs.pipDefaults[
62 "VulnerabilityDbMirror"]
63 safetyDbUrl = safetyDbUrl.replace("\\", "/")
64 if not safetyDbUrl.endswith("/"):
65 safetyDbUrl += "/"
66
67 Preferences.setPip("PipSearchIndex",
68 self.indexEdit.text().strip())
69
70 Preferences.setPip("VulnerabilityDbMirror", safetyDbUrl)
71 Preferences.setPip("VulnerabilityDbCacheValidity",
72 self.validitySpinBox.value() * 3600)
73 # hours converted to seconds
74
75 Preferences.setPip("ExcludeCondaEnvironments",
76 self.noCondaCheckBox.isChecked())
77
78
79 def create(dlg):
80 """
81 Module function to create the configuration page.
82
83 @param dlg reference to the configuration dialog
84 @return reference to the instantiated page (ConfigurationPageBase)
85 """
86 page = PipPage()
87 return page

eric ide

mercurial