Skip to content

Commit

Permalink
pylint and pep8 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezra Peisach committed Jun 27, 2024
1 parent 2a9d0ae commit b969a24
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ limit-inference-results=100

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins=pylint_pytest

# Pickle collected data for later comparisons.
persistent=yes
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ platform=
linux: linux
deps =
pylint
pylint-pytest
-r requirements.txt
commands =
echo "Starting {envname}"
Expand Down
34 changes: 14 additions & 20 deletions wwpdb/apps/ann_tasks_v2/pcm/PcmCCDEditorForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
"""

try:
import cPickle as pickle
except ImportError:
import pickle as pickle

import os
import csv
import sys
import logging
import traceback

from wwpdb.utils.dp.RcsbDpUtility import RcsbDpUtility
import logging

# Set the default logger handler level to INFO
logging.getLogger().setLevel(logging.INFO)
# Set the default logger handler level to INFO -- this should not be set here - but at hight level
# logging.getLogger().setLevel(logging.INFO)


class PcmCCDEditorForm(object):
Expand All @@ -44,11 +38,11 @@ def __setup(self):
self.__csvPath = os.path.join(self.__sessionPath, self.__entryId + "_ccd_no_pcm_ann.csv")
self.__entryFile = None
#
self.__listItemTemplate = (
'<li><a id="%s" class="discontrol ui-corner-all" href="#">'
+ '<span class="ui-icon fltlft ui-icon-circle-arrow-e"></span> %s </a>\n'
+ '<div id="display_%s" style="display:none"></div>\n</li>\n'
)
# self.__listItemTemplate = (
# '<li><a id="%s" class="discontrol ui-corner-all" href="#">'
# + '<span class="ui-icon fltlft ui-icon-circle-arrow-e"></span> %s </a>\n'
# + '<div id="display_%s" style="display:none"></div>\n</li>\n'
# )
#
self.__tableTemplate = '<table id="table_%s" class="table table-condensed table-bordered table-striped">\n'
self.__tdTagTemplate = '<td style="border-style:none">%s</td>\n'
Expand All @@ -69,12 +63,12 @@ def run(self):
#
if self.__identifier == self.__entryId:
self.__runPcmCcdCheck()

if os.access(self.__csvPath, os.F_OK):
return True
#
return False

def __runPcmCcdCheck(self):
"""Run X program"""
self.__entryFile = self.__reqObj.getValue("entryfilename")
Expand Down Expand Up @@ -109,11 +103,11 @@ def getCCDForm(self):
return self.__buildCCDFormHtml()
#
return myD

def __buildCCDFormHtml(self):
# depending on the output of the binary
# check if it matches this entry id

if not os.access(self.__csvPath, os.F_OK):
myD = {}
myD["statuscode"] = "failed"
Expand All @@ -122,7 +116,7 @@ def __buildCCDFormHtml(self):

htmlcontent = self.__tableTemplate % self.__identifier
htmlcontent += (
"<tr>\n<th>Comp Id</th>\n<th>Modified Residue Id</th>\n<th>Type</th>\n<th>Category</th>\n<th>Position</th>\n<th>Polypeptide Position</th>\n<th>Comp Id Linking Atom</th>\n<th>Modified Residue Id Linking Atom</th>\n<th>First Instance Model Db Code</th>\n<th>ChemRefUI Link</th>\n</tr>\n"
"<tr>\n<th>Comp Id</th>\n<th>Modified Residue Id</th>\n<th>Type</th>\n<th>Category</th>\n<th>Position</th>\n<th>Polypeptide Position</th>\n<th>Comp Id Linking Atom</th>\n<th>Modified Residue Id Linking Atom</th>\n<th>First Instance Model Db Code</th>\n<th>ChemRefUI Link</th>\n</tr>\n" # noqa: E501
)
#
columns = {
Expand All @@ -141,7 +135,7 @@ def __buildCCDFormHtml(self):
reader = csv.DictReader(csvfile)
for row in reader:
comp_id = row['Comp_id']

for c in columns:
if columns[c]['editable']:
ed_id = f"{comp_id}_{c}"
Expand All @@ -153,7 +147,7 @@ def __buildCCDFormHtml(self):
# add last column with link
chem_ref_link = "/chem_ref_data_ui/chemref_editor_bs.html?searchTarget=%s" % comp_id
htmlcontent += self.__tdTagTemplate % f'<a href="{chem_ref_link}" target="_blank">{comp_id}</a>'
htmlcontent += "</tr>\n"
htmlcontent += "</tr>\n"
#
htmlcontent += "</table>\n"
#
Expand Down
4 changes: 2 additions & 2 deletions wwpdb/apps/ann_tasks_v2/webapp/CommonTasksWebAppWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,8 @@ def _pcmGetCCDFormOp(self):
myD["statuscode"] = "running"
#
else:
entryId = self._reqObj.getValue("entryid")
identifier = self._reqObj.getValue("display_identifier")
# entryId = self._reqObj.getValue("entryid")
# identifier = self._reqObj.getValue("display_identifier")
dU.set(workerObj=ccdEditorFormOp, workerMethod="run")
dU.runDetach()
myD["statuscode"] = "running"
Expand Down
3 changes: 2 additions & 1 deletion wwpdb/apps/tests-ann/PcmPyTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

MOCK_SESSIONS_PATH = tempfile.mkdtemp()


@pytest.fixture
def mock_config(monkeypatch):
mc = {
Expand Down Expand Up @@ -54,7 +55,7 @@ def test_run_binary(mock_config):
pcm_form = PcmCCDEditorForm(reqObj=mock_req, verbose=False)
open(os.path.join(mock_req.session.getPath(), "1cbs.cif"), "w").close()

assert pcm_form.run() == True
assert pcm_form.run() is True
assert os.path.exists(os.path.join(mock_req.session.getPath(), "1cbs_ccd_no_pcm_ann.csv"))
assert os.path.exists(os.path.join(mock_req.session.getPath(), "1cbs_ccd_no_pcm_ann.log"))

Expand Down

0 comments on commit b969a24

Please sign in to comment.