From 37e10f0151dbd46374eb91df42f6b517c5dc21e5 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Fri, 5 Jul 2024 00:49:15 +0800 Subject: [PATCH 1/2] Follow PEP-8 standard fix issue. Leave 2 F401 error in formalletterbuilder.py in try statement with import modules. --- regolith/builders/beamplanbuilder.py | 13 +++++++------ regolith/builders/coabuilder.py | 5 +++-- regolith/builders/cpbuilder.py | 3 +-- regolith/builders/figurebuilder.py | 1 - regolith/builders/formalletterbuilder.py | 7 ++----- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/regolith/builders/beamplanbuilder.py b/regolith/builders/beamplanbuilder.py index 593b510b0..391f65be9 100644 --- a/regolith/builders/beamplanbuilder.py +++ b/regolith/builders/beamplanbuilder.py @@ -1,5 +1,6 @@ -"""Builder for the plan of beamtimes. The plan contains a summary of the information for the experiments in during a -beamtime and details about how to carry out the experiments.""" +"""Builder for the plan of beamtimes. +The plan contains a summary of the information for the experiments +in during a beamtime and details about how to carry out the experiments.""" from datetime import datetime @@ -11,10 +12,10 @@ class BeamPlanBuilder(LatexBuilderBase): """ - Build a file of experiment plans for the beamtime from database entries. The report is in .tex file. The template - of the file is in the 'templates/beamplan.tex'. The data will be grouped according to beamtime. Each beamtime - will generate a file of the plans. If 'beamtime' in 'rc' are not None, only plans for those beamtime will be - generated. + Build a file of experiment plans for the beamtime from database entries. The report is in .tex file. + The template of the file is in the 'templates/beamplan.tex'. The data will be grouped + according to beamtime. Each beamtime will generate a file of the plans. + If 'beamtime' in 'rc' are not None, only plans for those beamtime will be generated. Methods ------- diff --git a/regolith/builders/coabuilder.py b/regolith/builders/coabuilder.py index 5b9941d29..5354277c0 100644 --- a/regolith/builders/coabuilder.py +++ b/regolith/builders/coabuilder.py @@ -490,10 +490,11 @@ def query_ppl(self, target): except TypeError: print(f"ERROR: incorrect dates for an education/employment in {collab.get('name')}") print( - f"collab date: {collab.get('interaction_date')}, advisee date: {advis.get('interaction_date')}" + f"collab date: {collab.get('interaction_date')}, " + f"advisee date: {advis.get('interaction_date')}" ) raise - if col_bool == True: + if col_bool: collabs.append(collab) collabs.extend(advisees) collabs.extend(advisors) diff --git a/regolith/builders/cpbuilder.py b/regolith/builders/cpbuilder.py index 39d718b67..724c9dc0e 100644 --- a/regolith/builders/cpbuilder.py +++ b/regolith/builders/cpbuilder.py @@ -50,7 +50,6 @@ def construct_global_ctx(self): def latex(self): """Render latex template""" - gtx = self.gtx rc = self.rc for group in self.gtx["groups"]: self.gtx["grants"] = list(sorted(all_docs_from_collection(rc.client, "grants"), key=_id_key)) @@ -111,7 +110,7 @@ def latex(self): # badids_pending = ([i["_id"] for i in pending_grants if # not i.get('cpp_info',{}).get('cppflag', "")]) if badids: - print(f"these grants have a problem with ccp_info: {*badids,}") + print(f"these grants have a problem with ccp_info: {*badids, }") iter = copy(current_grants) for grant in iter: diff --git a/regolith/builders/figurebuilder.py b/regolith/builders/figurebuilder.py index 0709a7c4a..33468791c 100644 --- a/regolith/builders/figurebuilder.py +++ b/regolith/builders/figurebuilder.py @@ -28,7 +28,6 @@ def construct_global_ctx(self): def latex(self): """Render latex template""" - rc = self.rc for f in [ff for ff in os.listdir(".") if ff.endswith(".tex")]: fn, ext = os.path.splitext(f) self.render(f, fn + "_rend" + ext) diff --git a/regolith/builders/formalletterbuilder.py b/regolith/builders/formalletterbuilder.py index d1b65251e..912068d16 100644 --- a/regolith/builders/formalletterbuilder.py +++ b/regolith/builders/formalletterbuilder.py @@ -2,19 +2,17 @@ from datetime import datetime import string -import os from dateutil import parser as date_parser try: from bibtexparser.bwriter import BibTexWriter from bibtexparser.bibdatabase import BibDatabase - HAVE_BIBTEX_PARSER = True except ImportError: HAVE_BIBTEX_PARSER = False -from regolith.tools import all_docs_from_collection, filter_publications, make_bibtex_file -from regolith.sorters import ene_date_key, position_key +from regolith.tools import all_docs_from_collection +from regolith.sorters import position_key from regolith.builders.basebuilder import LatexBuilderBase LATEX_OPTS = ["-halt-on-error", "-file-line-error"] @@ -60,7 +58,6 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - fd = gr = False filestub, qualifiers = "", "" if self.rc.from_date: from_date = date_parser.parse(self.rc.from_date).date() From 83b04df8de57bc0c77ab057fe671879497e91182 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Thu, 4 Jul 2024 14:09:00 -0400 Subject: [PATCH 2/2] docstring tweak --- regolith/builders/beamplanbuilder.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/regolith/builders/beamplanbuilder.py b/regolith/builders/beamplanbuilder.py index 391f65be9..ef1de1fe3 100644 --- a/regolith/builders/beamplanbuilder.py +++ b/regolith/builders/beamplanbuilder.py @@ -1,6 +1,9 @@ -"""Builder for the plan of beamtimes. +"""Builder for the planning of beamtimes. + The plan contains a summary of the information for the experiments -in during a beamtime and details about how to carry out the experiments.""" +in during a beamtime and details about how to carry out the experiments. + +""" from datetime import datetime @@ -12,8 +15,10 @@ class BeamPlanBuilder(LatexBuilderBase): """ - Build a file of experiment plans for the beamtime from database entries. The report is in .tex file. - The template of the file is in the 'templates/beamplan.tex'. The data will be grouped + Build a file of experiment plans for the beamtime from database entries. + + The report is in the .tex file. The template of the file is in the + 'templates/beamplan.tex'. The data will be grouped according to beamtime. Each beamtime will generate a file of the plans. If 'beamtime' in 'rc' are not None, only plans for those beamtime will be generated.