diff --git a/.github/ISSUE_TEMPLATE/release_checklist.md b/.github/ISSUE_TEMPLATE/release_checklist.md index b96c782de..71c76d412 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.md +++ b/.github/ISSUE_TEMPLATE/release_checklist.md @@ -6,23 +6,41 @@ labels: "release" assignees: "" --- -### Release checklist for GitHub contributors +### PyPI/GitHub rc-release preparation checklist: - [ ] All PRs/issues attached to the release are merged. - [ ] All the badges on the README are passing. - [ ] License information is verified as correct. If you are unsure, please comment below. - [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are - missing), tutorials, and other human written text is up-to-date with any changes in the code. -- [ ] Installation instructions in the README, documentation and on the website (e.g., diffpy.org) updated. -- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version -- [ ] Grammar and writing quality have been checked (no typos). + missing), tutorials, and other human-written text is up-to-date with any changes in the code. +- [ ] Installation instructions in the README, documentation, and the website (e.g., diffpy.org) are updated. +- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version. +- [ ] Grammar and writing quality are checked (no typos). +- [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release. -Please mention @sbillinge when you are ready for release. Include any additional comments necessary, such as -version information and details about the pre-release here: +Please mention @sbillinge here when you are ready for PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here: + +### PyPI/GitHub full-release preparation checklist: + +- [ ] Create a new conda environment and install the rc from PyPI (`pip install ==??`) +- [ ] License information on PyPI is correct. +- [ ] Docs are deployed successfully to `https://www.diffpy.org/`. +- [ ] Successfully run all tests, tutorial examples or do functional testing. + +Please let @sbillinge know that all checks are done and the package is ready for full release. + +### conda-forge release preparation checklist: + + + +- [ ] Ensure that the full release has appeared on PyPI successfully. +- [ ] New package dependencies listed in `conda.txt` and `test.txt` are added to `meta.yaml` in the feedstock. +- [ ] Close any open issues on the feedstock. Reach out to @bobleesj if you have questions. +- [ ] Tag @sbillinge and @bobleesj for conda-forge release. ### Post-release checklist -Before closing this issue, please complete the following: + - [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. - [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4344aeba1..008c129ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ default_language_version: - python: python3 + python: python3 ci: - autofix_commit_msg: | - [pre-commit.ci] auto fixes from pre-commit hooks - autofix_prs: true - autoupdate_branch: 'pre-commit-autoupdate' - autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' - autoupdate_schedule: monthly - skip: [no-commit-to-branch] - submodules: false + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit hooks + autofix_prs: true + autoupdate_branch: "pre-commit-autoupdate" + autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" + autoupdate_schedule: monthly + skip: [no-commit-to-branch] + submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 @@ -46,9 +46,25 @@ repos: name: Prevent Commit to Main Branch args: ["--branch", "main"] stages: [pre-commit] + # codespell - spell checker for source code - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: - - id: codespell - additional_dependencies: - - tomli + - id: codespell + additional_dependencies: + - tomli + # prettier - multi formatter for json, yaml, md + - repo: https://github.com/pre-commit/mirrors-prettier + rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8 + hooks: + - id: prettier + exclude: '.*\.(html|json|css|js|yml|yaml|md)$' + additional_dependencies: + - "prettier@^3.2.4" + # docformatter - formats docstrings using PEP 257 + - repo: https://github.com/s-weigand/docformatter + rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + hooks: + - id: docformatter + additional_dependencies: [tomli] + args: [--in-place, --config, ./pyproject.toml] diff --git a/news/doc-format.rst b/news/doc-format.rst new file mode 100644 index 000000000..9164f7717 --- /dev/null +++ b/news/doc-format.rst @@ -0,0 +1,24 @@ +**Added:** + +* 'prettier' and 'docformatter' added to .pre-commit-configs.yml +* PyPI/Github full-release nd conda-forge release checklist added. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/regolith/broker.py b/src/regolith/broker.py index 1c7b26f81..0c01fa233 100644 --- a/src/regolith/broker.py +++ b/src/regolith/broker.py @@ -1,4 +1,4 @@ -"""API for accessing the metadata and file storage""" +"""API for accessing the metadata and file storage.""" import copy @@ -8,7 +8,7 @@ def load_db(rc_file="regolithrc.json"): - """Create a Broker instance from an rc file""" + """Create a Broker instance from an rc file.""" rc = copy.copy(DEFAULT_RC) rc._update(load_rcfile(rc_file)) filter_databases(rc) @@ -16,7 +16,7 @@ def load_db(rc_file="regolithrc.json"): class Broker: - """Interface to the database and file storage systems + """Interface to the database and file storage systems. Examples -------- @@ -63,12 +63,12 @@ def add_file(self, document, name, filepath): @classmethod def from_rc(cls, rc_file="regolithrc.json"): - """Return a Broker instance""" + """Return a Broker instance.""" return load_db(rc_file) def get_file_path(self, document, name): """Get a file from the file storage associated with the document and - name + name. Parameters ---------- diff --git a/src/regolith/builders/activitylogbuilder.py b/src/regolith/builders/activitylogbuilder.py index 162cf7432..187f5da82 100644 --- a/src/regolith/builders/activitylogbuilder.py +++ b/src/regolith/builders/activitylogbuilder.py @@ -34,7 +34,7 @@ class ActivitylogBuilder(LatexBuilderBase): - """Build CV from database entries""" + """Build CV from database entries.""" btype = "annual-activity" needed_colls = [ @@ -54,7 +54,7 @@ class ActivitylogBuilder(LatexBuilderBase): ] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -80,7 +80,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" rc = self.rc group = fuzzy_retrieval(self.gtx["groups"], ["_id", "aka", "name"], rc.groupname) if not rc.people: diff --git a/src/regolith/builders/appraisalbuilder.py b/src/regolith/builders/appraisalbuilder.py index 5f9688b93..3531a4763 100644 --- a/src/regolith/builders/appraisalbuilder.py +++ b/src/regolith/builders/appraisalbuilder.py @@ -29,7 +29,7 @@ class AppraisalBuilder(LatexBuilderBase): - """Build CV from database entries""" + """Build CV from database entries.""" btype = "annual-activity" needed_colls = [ @@ -45,7 +45,7 @@ class AppraisalBuilder(LatexBuilderBase): ] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -66,7 +66,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" rc = self.rc if not rc.people: raise RuntimeError("ERROR: please rerun specifying --people name") diff --git a/src/regolith/builders/basebuilder.py b/src/regolith/builders/basebuilder.py index 8cd8d7fd6..ca1afb548 100644 --- a/src/regolith/builders/basebuilder.py +++ b/src/regolith/builders/basebuilder.py @@ -1,4 +1,4 @@ -"""Builder Base Classes""" +"""Builder Base Classes.""" import os from glob import glob @@ -20,7 +20,7 @@ class BuilderBase(object): - """Base class for builders""" + """Base class for builders.""" def __init__(self, rc): self.rc = rc @@ -43,7 +43,7 @@ def __init__(self, rc): self.cmds = [] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" gtx = self.gtx gtx["len"] = len gtx["True"] = True @@ -60,7 +60,7 @@ def construct_global_ctx(self): gtx["date_to_rfc822"] = date_to_rfc822 def render(self, tname, fname, **kwargs): - """Render the template into a file using the kwargs and global context + """Render the template into a file using the kwargs and global context. Parameters ---------- @@ -90,7 +90,7 @@ def build(self): class LatexBuilderBase(BuilderBase): - """Base class for Latex builders""" + """Base class for Latex builders.""" def __init__(self, rc): super().__init__(rc) @@ -107,11 +107,11 @@ def construct_global_ctx(self): gtx["latex_safe_url"] = latex_safe_url def run(self, cmd): - """Run command in build dir""" + """Run command in build dir.""" subprocess.run(cmd, cwd=self.bldir, check=True) def pdf(self, base): - """Compiles latex files to PDF""" + """Compiles latex files to PDF.""" if self.rc.pdf: if os.name == "nt": self.run(["pdflatex"] + LATEX_OPTS + [base + ".tex"]) @@ -120,7 +120,7 @@ def pdf(self, base): self.run(["dvipdf", base]) def clean(self): - """Remove files created by latex""" + """Remove files created by latex.""" postfixes = [ "*.dvi", "*.toc", diff --git a/src/regolith/builders/beamplanbuilder.py b/src/regolith/builders/beamplanbuilder.py index 5d5c254c2..426f6c11f 100644 --- a/src/regolith/builders/beamplanbuilder.py +++ b/src/regolith/builders/beamplanbuilder.py @@ -1,8 +1,7 @@ """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. - +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 @@ -14,8 +13,7 @@ class BeamPlanBuilder(LatexBuilderBase): - """ - Build a file of experiment plans for the beamtime from database entries. + """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 @@ -60,9 +58,8 @@ def _search(db, key): return None def _gather_info(self, bt, docs): - """ - Query information from the list of documents. Return a table as the summary of the plans and a list of - experiment plans. + """Query information from the list of documents. Return a table as the + summary of the plans and a list of experiment plans. Parameters ---------- diff --git a/src/regolith/builders/coabuilder.py b/src/regolith/builders/coabuilder.py index c544eabc8..ce2ff624f 100644 --- a/src/regolith/builders/coabuilder.py +++ b/src/regolith/builders/coabuilder.py @@ -1,9 +1,9 @@ """Builder for Recent Collaborators. For the specified person it returns the name and institution of all -graduate student and post-doc advisors, -all graduate student advisees, all post-doc advisees in the past 60 months -and all coauthors in the past 48 months. +graduate student and post-doc advisors, all graduate student advisees, +all post-doc advisees in the past 60 months and all coauthors in the +past 48 months. """ import datetime as dt @@ -25,7 +25,10 @@ def get_advisors_name_inst(advisee, rc): - """Get the advisee's advisor. Yield (last name, first name, institution name).""" + """Get the advisee's advisor. + + Yield (last name, first name, institution name). + """ phd_advisors = [ { @@ -52,7 +55,10 @@ def get_advisors_name_inst(advisee, rc): def get_advisees_name_inst(coll, advisor, rc): - """Get advisor's advisees. Yield (last name, first name, institutions)""" + """Get advisor's advisees. + + Yield (last name, first name, institutions) + """ advisor_names = advisor.get("aka", []) + [advisor.get("name"), advisor.get("_id")] advisees = [] for person in coll: @@ -118,7 +124,10 @@ def get_since_dates(rc): def get_coauthors_from_pubs(rc, pubs, not_person): - """Get co-authors' names from the publication. Not include the person itself.""" + """Get co-authors' names from the publication. + + Not include the person itself. + """ not_person_akas = [not_person["_id"], not_person["name"]] + not_person["aka"] my_collabs = list() for pub in pubs: @@ -313,7 +322,10 @@ def format_last_first_institution_names(rc, ppl_names, excluded_inst_name=None): def format_to_nsf(tups, type_str): - """Format the 3 tups to 2 tups. ('type_str', 'last, first', 'inst', ...).""" + """Format the 3 tups to 2 tups. + + ('type_str', 'last, first', 'inst', ...). + """ return [(type_str, "{}, {}".format(tup[0], tup[1])) + tup[2:] for tup in tups] @@ -386,7 +398,10 @@ def get_person(person_id, rc): def find_coeditors(person, rc): - """Get the coeditors info of the person. Return (last, first, inst, journal).""" + """Get the coeditors info of the person. + + Return (last, first, inst, journal). + """ emps = person.get("employment") if emps is None: return set() @@ -409,7 +424,7 @@ def coeditor_id_journals(_emps): class RecentCollaboratorsBuilder(BuilderBase): - """Build recent collaborators from database entries""" + """Build recent collaborators from database entries.""" btype = "recent-collabs" needed_colls = ["citations", "people", "contacts", "institutions"] @@ -516,7 +531,8 @@ def query_ppl(self, target): @staticmethod def fill_in_tab(ws, ppl, start_row, template_cell_style=None, cols="ABCDE"): - """Add the information in person, institution pairs into the table 4 in nsf table.""" + """Add the information in person, institution pairs into the table 4 in + nsf table.""" nsf_mappings = { "co-author": "A:", "collaborator": "C:", diff --git a/src/regolith/builders/cpbuilder.py b/src/regolith/builders/cpbuilder.py index 8156ee4a1..bef76038f 100644 --- a/src/regolith/builders/cpbuilder.py +++ b/src/regolith/builders/cpbuilder.py @@ -21,13 +21,13 @@ def is_declined(status): class CPBuilder(LatexBuilderBase): - """Build current and pending report from database entries""" + """Build current and pending report from database entries.""" btype = "current-pending" needed_colls = ["groups", "people", "grants", "proposals"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -45,7 +45,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" rc = self.rc for group in self.gtx["groups"]: self.gtx["grants"] = list(sorted(all_docs_from_collection(rc.client, "grants"), key=_id_key)) diff --git a/src/regolith/builders/cvbuilder.py b/src/regolith/builders/cvbuilder.py index 2016f3fe6..7e35faf0c 100644 --- a/src/regolith/builders/cvbuilder.py +++ b/src/regolith/builders/cvbuilder.py @@ -24,13 +24,13 @@ class CVBuilder(LatexBuilderBase): - """Build CV from database entries""" + """Build CV from database entries.""" btype = "cv" needed_colls = ["institutions", "people", "grants", "citations", "projects", "proposals", "presentations"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -47,7 +47,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" rc = self.rc gtx = self.gtx if rc.people: diff --git a/src/regolith/builders/figurebuilder.py b/src/regolith/builders/figurebuilder.py index 33468791c..5977f2e4f 100644 --- a/src/regolith/builders/figurebuilder.py +++ b/src/regolith/builders/figurebuilder.py @@ -10,7 +10,7 @@ class FigureBuilder(LatexBuilderBase): - """Build resume from database entries""" + """Build resume from database entries.""" btype = "figure" @@ -27,7 +27,7 @@ def construct_global_ctx(self): gtx["fuzzy_retrieval"] = fuzzy_retrieval def latex(self): - """Render latex template""" + """Render latex template.""" 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/src/regolith/builders/gradebuilder.py b/src/regolith/builders/gradebuilder.py index fa950944b..3d7a43d98 100644 --- a/src/regolith/builders/gradebuilder.py +++ b/src/regolith/builders/gradebuilder.py @@ -130,10 +130,9 @@ def latex(self): self.pdf(base) def makestats(self, course): - """Returns a dictionary of statistics for a course whose keys are - the assignments and whose values are a (mean-problem, std-problem, - mean-total, std-total) tuple. - """ + """Returns a dictionary of statistics for a course whose keys are the + assignments and whose values are a (mean-problem, std-problem, mean- + total, std-total) tuple.""" scores = {} course_id = course["_id"] for grade in self.gtx["grades"]: @@ -212,7 +211,7 @@ def maketotals(self, student_grades, grouped_assignments, course): return sorted(totals), wtotal def plot_letter_grades(self, students_kwargs, scale): - """Plots the letter grades in a histogram""" + """Plots the letter grades in a histogram.""" try: import matplotlib.pyplot as plt except ImportError: diff --git a/src/regolith/builders/grantreportbuilder.py b/src/regolith/builders/grantreportbuilder.py index a790c78ca..ff6bed9c7 100644 --- a/src/regolith/builders/grantreportbuilder.py +++ b/src/regolith/builders/grantreportbuilder.py @@ -1,4 +1,4 @@ -"""Builder for Grant Reports""" +"""Builder for Grant Reports.""" from datetime import date @@ -14,7 +14,7 @@ class GrantReportBuilder(LatexBuilderBase): - """Build a proposal review from database entries""" + """Build a proposal review from database entries.""" btype = "grant-report" needed_dbs = [ @@ -33,7 +33,7 @@ class GrantReportBuilder(LatexBuilderBase): # self.needed_dbs = needed_dbs def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -45,7 +45,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" rc = self.rc if not rc.grants: diff --git a/src/regolith/builders/htmlbuilder.py b/src/regolith/builders/htmlbuilder.py index 392f4aed9..11b775a44 100644 --- a/src/regolith/builders/htmlbuilder.py +++ b/src/regolith/builders/htmlbuilder.py @@ -18,7 +18,7 @@ class HtmlBuilder(BuilderBase): - """Build HTML files for website""" + """Build HTML files for website.""" btype = "html" @@ -38,7 +38,7 @@ def __init__(self, rc): ] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -55,7 +55,7 @@ def construct_global_ctx(self): def finish(self): """Move files over to their destination and remove them from the - source""" + source.""" # static stsrc = os.path.join(getattr(self.rc, "static_source", "templates"), "static") stdst = os.path.join(self.bldir, "static") @@ -65,7 +65,7 @@ def finish(self): shutil.copytree(stsrc, stdst) def root_index(self): - """Render root index""" + """Render root index.""" self.render("root_index.html", "index.html", title="Home") make_bibtex_file( list(all_docs_from_collection(self.rc.client, "citations")), @@ -74,7 +74,7 @@ def root_index(self): ) def people(self): - """Render people, former members, and each person""" + """Render people, former members, and each person.""" rc = self.rc peeps_dir = os.path.join(self.bldir, "people") former_peeps_dir = os.path.join(self.bldir, "former") @@ -132,13 +132,13 @@ def people(self): ) def projects(self): - """Render projects""" + """Render projects.""" rc = self.rc projs = all_docs_from_collection(rc.client, "projects") self.render("projects.html", "projects.html", title="Projects", projects=projs) def blog(self): - """Render the blog and rss""" + """Render the blog and rss.""" rc = self.rc blog_dir = os.path.join(self.bldir, "blog") os.makedirs(blog_dir, exist_ok=True) @@ -160,7 +160,7 @@ def blog(self): self.render("rss.xml", os.path.join("blog", "rss.xml"), items=posts) def jobs(self): - """Render the jobs and each job""" + """Render the jobs and each job.""" jobs_dir = os.path.join(self.bldir, "jobs") os.makedirs(jobs_dir, exist_ok=True) for job in self.gtx["jobs"]: @@ -173,7 +173,7 @@ def jobs(self): self.render("jobs.html", os.path.join("jobs", "index.html"), title="Jobs") def abstracts(self): - """Render each abstract""" + """Render each abstract.""" abs_dir = os.path.join(self.bldir, "abstracts") os.makedirs(abs_dir, exist_ok=True) for ab in self.gtx["abstracts"]: @@ -185,12 +185,12 @@ def abstracts(self): ) def nojekyll(self): - """Touches a nojekyll file in the build dir""" + """Touches a nojekyll file in the build dir.""" with open(os.path.join(self.bldir, ".nojekyll"), "a+"): pass def cname(self): - """Add CNAME""" + """Add CNAME.""" rc = self.rc if not hasattr(rc, "cname"): return diff --git a/src/regolith/builders/internalhtmlbuilder.py b/src/regolith/builders/internalhtmlbuilder.py index 9cc817d1a..2d7145d02 100644 --- a/src/regolith/builders/internalhtmlbuilder.py +++ b/src/regolith/builders/internalhtmlbuilder.py @@ -23,7 +23,7 @@ class InternalHtmlBuilder(BuilderBase): - """Build HTML files for website""" + """Build HTML files for website.""" btype = "internalhtml" needed_colls = ["people", "meetings"] @@ -39,7 +39,7 @@ def __init__(self, rc): ] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -56,7 +56,7 @@ def construct_global_ctx(self): def finish(self): """Move files over to their destination and remove them from the - source""" + source.""" # static stsrc = os.path.join(getattr(self.rc, "static_source", "templates"), "static") stdst = os.path.join(self.bldir, "static") @@ -65,11 +65,11 @@ def finish(self): shutil.copytree(stsrc, stdst) def root_index(self): - """Render root index""" + """Render root index.""" self.render("introot_index.html", "intindex.html", title="Home") def meetings(self): - """Render projects""" + """Render projects.""" rc = self.rc mtgsi = all_docs_from_collection(rc.client, "meetings") @@ -153,12 +153,12 @@ def meetings(self): ) def nojekyll(self): - """Touches a nojekyll file in the build dir""" + """Touches a nojekyll file in the build dir.""" with open(os.path.join(self.bldir, ".nojekyll"), "a+"): pass def cname(self): - """Add CNAME""" + """Add CNAME.""" rc = self.rc if not hasattr(rc, "cname"): return @@ -166,7 +166,7 @@ def cname(self): f.write(rc.cname) def people(self): - """Render people, former members, and each person""" + """Render people, former members, and each person.""" rc = self.rc peeps_dir = os.path.join(self.bldir, "people") former_peeps_dir = os.path.join(self.bldir, "former") @@ -208,13 +208,13 @@ def people(self): ) def projects(self): - """Render projects""" + """Render projects.""" rc = self.rc projs = all_docs_from_collection(rc.client, "projects") self.render("projects.html", "projects.html", title="Projects", projects=projs) def blog(self): - """Render the blog and rss""" + """Render the blog and rss.""" rc = self.rc blog_dir = os.path.join(self.bldir, "blog") os.makedirs(blog_dir, exist_ok=True) @@ -236,7 +236,7 @@ def blog(self): self.render("rss.xml", os.path.join("blog", "rss.xml"), items=posts) def jobs(self): - """Render the jobs and each job""" + """Render the jobs and each job.""" jobs_dir = os.path.join(self.bldir, "jobs") os.makedirs(jobs_dir, exist_ok=True) for job in self.gtx["jobs"]: @@ -249,7 +249,7 @@ def jobs(self): self.render("jobs.html", os.path.join("jobs", "index.html"), title="Jobs") def abstracts(self): - """Render each abstract""" + """Render each abstract.""" abs_dir = os.path.join(self.bldir, "abstracts") os.makedirs(abs_dir, exist_ok=True) for ab in self.gtx["abstracts"]: diff --git a/src/regolith/builders/manuscriptreviewbuilder.py b/src/regolith/builders/manuscriptreviewbuilder.py index 30595ff9b..6695eb199 100644 --- a/src/regolith/builders/manuscriptreviewbuilder.py +++ b/src/regolith/builders/manuscriptreviewbuilder.py @@ -6,13 +6,13 @@ class ManRevBuilder(LatexBuilderBase): - """Build a manuscript review from database entries""" + """Build a manuscript review from database entries.""" btype = "review-man" needed_colls = ["refereeReports"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -23,7 +23,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" for rev in self.gtx["refereeReports"]: outname = "{}_{}".format(_id_key(rev), rev["reviewer"]) self.render( diff --git a/src/regolith/builders/postdocadbuilder.py b/src/regolith/builders/postdocadbuilder.py index a605676f2..b4713c015 100644 --- a/src/regolith/builders/postdocadbuilder.py +++ b/src/regolith/builders/postdocadbuilder.py @@ -6,13 +6,13 @@ class PostdocadBuilder(LatexBuilderBase): - """Build current and pending report from database entries""" + """Build current and pending report from database entries.""" btype = "postdocads" needed_colls = ["postdocads"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -23,7 +23,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" for ads in self.gtx["postdocads"]: goals = ads["projectGoals"] positionOn = ads["positionOn"] diff --git a/src/regolith/builders/preslistbuilder.py b/src/regolith/builders/preslistbuilder.py index 335fb33ec..8cc72016a 100644 --- a/src/regolith/builders/preslistbuilder.py +++ b/src/regolith/builders/preslistbuilder.py @@ -1,22 +1,24 @@ """Builder for Lists of Presentations. -This builder will build a presentation list for each group-member in each group -listed in groups.yml. Group members are indicated in the employment and -education sections of the individual in people.yml. +This builder will build a presentation list for each group-member in +each group listed in groups.yml. Group members are indicated in the +employment and education sections of the individual in people.yml. -There are a number of filtering options, i.e., for presentation-type (invited, -colloquium, seminar, poster, contributed_oral) and for whether the invitation -was accepted or declined. As of now, these filters can only be updated by -editing this file but may appear as command-line options later. It will also -get institution and department information from institutions.yml if they are -there. +There are a number of filtering options, i.e., for presentation-type +(invited, colloquium, seminar, poster, contributed_oral) and for whether +the invitation was accepted or declined. As of now, these filters can +only be updated by editing this file but may appear as command-line +options later. It will also get institution and department information +from institutions.yml if they are there. -The author list is built from information in people.yml where possible and -contacts.yml as a fallback. The author list is built by first performing a -fuzzy search for the person in people.yml, followed by a fuzzy search through -contacts.yml (if the person was not found in people.yml), but if the person is -absent both database files, it will still build but using the string name given -in the presentations.yml. The presentations are output in a ./_build directory.""" +The author list is built from information in people.yml where possible +and contacts.yml as a fallback. The author list is built by first +performing a fuzzy search for the person in people.yml, followed by a +fuzzy search through contacts.yml (if the person was not found in +people.yml), but if the person is absent both database files, it will +still build but using the string name given in the presentations.yml. +The presentations are output in a ./_build directory. +""" from regolith.builders.basebuilder import LatexBuilderBase from regolith.fsclient import _id_key @@ -26,13 +28,14 @@ class PresListBuilder(LatexBuilderBase): - """Build list of talks and posters (presentations) from database entries""" + """Build list of talks and posters (presentations) from database + entries.""" btype = "preslist" needed_colls = ["groups", "institutions", "people", "grants", "presentations", "contacts"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -56,7 +59,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" everybody = self.gtx["people"] + self.gtx["contacts"] for group in self.gtx["groups"]: grp = group["_id"] diff --git a/src/regolith/builders/proposalreviewbuilder.py b/src/regolith/builders/proposalreviewbuilder.py index e23abd180..256252b1c 100644 --- a/src/regolith/builders/proposalreviewbuilder.py +++ b/src/regolith/builders/proposalreviewbuilder.py @@ -8,13 +8,13 @@ class PropRevBuilder(LatexBuilderBase): - """Build a proposal review from database entries""" + """Build a proposal review from database entries.""" btype = "review-prop" needed_colls = ["institutions", "proposalReviews"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -26,7 +26,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" for rev in self.gtx["proposalReviews"]: outname = "{}_{}".format(_id_key(rev), rev["reviewer"]) multiauth = False diff --git a/src/regolith/builders/readinglistsbuilder.py b/src/regolith/builders/readinglistsbuilder.py index c5152cc09..436dbe95f 100644 --- a/src/regolith/builders/readinglistsbuilder.py +++ b/src/regolith/builders/readinglistsbuilder.py @@ -9,13 +9,13 @@ class ReadingListsBuilder(LatexBuilderBase): - """Build reading lists from database entries""" + """Build reading lists from database entries.""" btype = "readinglists" needed_colls = ["people", "reading_lists"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -33,7 +33,7 @@ def construct_global_ctx(self): gtx["zip"] = zip def latex(self): - """Render latex template""" + """Render latex template.""" # build the collection of formatted references so that we only go # and fetch the formatted references once per doi diff --git a/src/regolith/builders/reimbursementbuilder.py b/src/regolith/builders/reimbursementbuilder.py index 84d366ed3..78d18f90b 100644 --- a/src/regolith/builders/reimbursementbuilder.py +++ b/src/regolith/builders/reimbursementbuilder.py @@ -11,7 +11,7 @@ class ReimbursementBuilder(BuilderBase): - """Build reimbursement from database entries""" + """Build reimbursement from database entries.""" btype = "reimb" needed_colls = ["expenses", "people", "grants"] @@ -23,7 +23,7 @@ def __init__(self, rc): self.cmds = ["excel"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/builders/resumebuilder.py b/src/regolith/builders/resumebuilder.py index 5b892a0e6..8ee6a81a3 100644 --- a/src/regolith/builders/resumebuilder.py +++ b/src/regolith/builders/resumebuilder.py @@ -17,13 +17,13 @@ class ResumeBuilder(LatexBuilderBase): - """Build resume from database entries""" + """Build resume from database entries.""" btype = "resume" needed_colls = ["institutions", "people", "grants", "citations", "projects", "proposals"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -37,7 +37,7 @@ def construct_global_ctx(self): gtx["all_docs_from_collection"] = all_docs_from_collection def latex(self): - """Render latex template""" + """Render latex template.""" rc = self.rc if rc.people: people = [fuzzy_retrieval(self.gtx["people"], ["aka", "_id", "name"], rc.people[0])] diff --git a/src/regolith/chained_db.py b/src/regolith/chained_db.py index 551415349..8fc615927 100644 --- a/src/regolith/chained_db.py +++ b/src/regolith/chained_db.py @@ -1,7 +1,6 @@ -"""Base class for chaining DBs +"""Base class for chaining DBs. -ChainDBSingleton -Copyright 2015-2016, the xonsh developers +ChainDBSingleton Copyright 2015-2016, the xonsh developers """ import itertools @@ -24,8 +23,8 @@ def __new__(cls): class ChainDB(ChainMap): - """A ChainMap who's ``_getitem__`` returns either a ChainDB or - the result""" + """A ChainMap who's ``_getitem__`` returns either a ChainDB or the + result.""" def __getitem__(self, key): res = None diff --git a/src/regolith/classlist.py b/src/regolith/classlist.py index 2c7abd460..096048043 100644 --- a/src/regolith/classlist.py +++ b/src/regolith/classlist.py @@ -1,4 +1,4 @@ -"""Classlist implementation""" +"""Classlist implementation.""" import csv import json @@ -19,7 +19,8 @@ def load_json(filename): def load_csv(filename, format="columbia"): - """Returns students as a list of dicts from a csv from Columbia Courseworks""" + """Returns students as a list of dicts from a csv from Columbia + Courseworks.""" with open(filename, encoding="utf-8") as f: reader = csv.DictReader(f) students = [] @@ -123,9 +124,8 @@ def handle_data(self, data): def load_usc(filename): - """Returns students as a list of dicts from an HTML file obtainted from the University of - South Carolina. - """ + """Returns students as a list of dicts from an HTML file obtainted from the + University of South Carolina.""" with open(filename, encoding="utf-8") as f: html = f.read() parser = UscHtmlParser() @@ -143,7 +143,7 @@ def add_students_to_db(students, rc): def add_students_to_course(students, rc): - """Add students to the course listed""" + """Add students to the course listed.""" course = rc.client.find_one(rc.db, "courses", {"_id": rc.course_id}) if not course: raise ValueError(f"no course {rc.course_id} found in database") diff --git a/src/regolith/client_manager.py b/src/regolith/client_manager.py index 3b9c792ec..1c1aa26d1 100644 --- a/src/regolith/client_manager.py +++ b/src/regolith/client_manager.py @@ -13,9 +13,8 @@ class ClientManager: - """ - Client wrapper that allows for multiple backend clients to be used in parallel with one chained DB - """ + """Client wrapper that allows for multiple backend clients to be used in + parallel with one chained DB.""" def __init__(self, databases, rc): client_tuple = tuple() @@ -55,7 +54,7 @@ def __getitem__(self, key): return client[key] def open(self): - """Opens the database connections""" + """Opens the database connections.""" for client in self.clients: client.open() @@ -121,7 +120,7 @@ def insert_many(self, dbname, collname, docs): client.insert_many(dbname, collname, docs) def delete_one(self, dbname, collname, doc): - """Removes a single document from a collection""" + """Removes a single document from a collection.""" for client in self.clients: if dbname in client.keys(): client.delete_one(dbname, collname, doc) diff --git a/src/regolith/commands.py b/src/regolith/commands.py index 82e0f6965..8669bf26e 100644 --- a/src/regolith/commands.py +++ b/src/regolith/commands.py @@ -90,21 +90,21 @@ def _run_app(app, rc): def app(rc): - """Runs flask app""" + """Runs flask app.""" from regolith.app import app _run_app(app, rc) def grade(rc): - """Runs flask grading app""" + """Runs flask grading app.""" from regolith.grader import app _run_app(app, rc) def build_db_check(rc): - """Checks which DBs a builder needs""" + """Checks which DBs a builder needs.""" dbs = set() for t in rc.build_targets: bldr = BUILDERS[t] @@ -118,7 +118,7 @@ def build_db_check(rc): def helper_db_check(rc): - """Checks which DBs a builder needs""" + """Checks which DBs a builder needs.""" # if the helper is an fast_updater, only open the database from rc.database rc.fast_updater = False for helperkey in UPDATER_HELPERS.keys(): @@ -142,14 +142,14 @@ def helper_db_check(rc): def build(rc): - """Builds all of the build targets""" + """Builds all of the build targets.""" for t in rc.build_targets: bldr = builder(t, rc) bldr.build() def helper(rc): - """Runs the helper targets""" + """Runs the helper targets.""" hlpr = helpr(rc.helper_target, rc) hlpr.hlp() @@ -170,7 +170,7 @@ def classlist(rc): def json_to_yaml(rc): - """Converts JSON to YAML""" + """Converts JSON to YAML.""" from regolith import fsclient for inp in rc.files: @@ -180,7 +180,7 @@ def json_to_yaml(rc): def yaml_to_json(rc): - """Converts YAML to JSON""" + """Converts YAML to JSON.""" from regolith import fsclient for inp in rc.files: @@ -223,7 +223,7 @@ def mongo_to_fs(rc: RunControl) -> None: def validate(rc): - """Validate the combined database against the schemas""" + """Validate the combined database against the schemas.""" from regolith.schemas import validate print("=" * 10 + "\nVALIDATING\n") diff --git a/src/regolith/dates.py b/src/regolith/dates.py index 1d3aa0c46..6c67676c8 100644 --- a/src/regolith/dates.py +++ b/src/regolith/dates.py @@ -1,4 +1,4 @@ -"""Date based tools""" +"""Date based tools.""" import calendar import datetime @@ -58,7 +58,7 @@ def month_to_int(m): def month_to_str_int(m): - """Converts a month to an int form, str type, with a leading zero""" + """Converts a month to an int form, str type, with a leading zero.""" mi = month_to_int(m) if mi < 10: ms = "0{}".format(mi) @@ -68,7 +68,7 @@ def month_to_str_int(m): def day_to_str_int(d): - """Converts a day to an int form, str type, with a leading zero""" + """Converts a day to an int form, str type, with a leading zero.""" if d < 10: ds = "0{}".format(d) else: @@ -77,8 +77,8 @@ def day_to_str_int(d): def date_to_float(y, m, d=0): - """Converts years / months / days to a float, eg 2015.0818 is August - 18th 2015.""" + """Converts years / months / days to a float, eg 2015.0818 is August 18th + 2015.""" y = int(y) m = month_to_int(m) d = int(d) @@ -86,8 +86,7 @@ def date_to_float(y, m, d=0): def find_gaps_overlaps(dateslist, overlaps_ok=False): - """ - Find whether there is a gap or an overlap in a list of date-ranges + """Find whether there is a gap or an overlap in a list of date-ranges. Parameters ---------- @@ -99,7 +98,6 @@ def find_gaps_overlaps(dateslist, overlaps_ok=False): Returns ------- True if there are no gaps or overlaps else False - """ status = True @@ -113,8 +111,7 @@ def find_gaps_overlaps(dateslist, overlaps_ok=False): def last_day(year, month): - """ - Returns the last day of the month for the month given + """Returns the last day of the month for the month given. Parameters ---------- @@ -126,16 +123,14 @@ def last_day(year, month): Returns ------- The last day of that month - """ return calendar.monthrange(year, month_to_int(month))[1] def convert_doc_iso_to_date(doc): def convert_date(obj): - """ - Recursively goes through the dictionary obj and converts date from iso to datetime.date - """ + """Recursively goes through the dictionary obj and converts date from + iso to datetime.date.""" if isinstance(obj, str): try: date = datetime.datetime.strptime(obj, "%Y-%m-%d").date() @@ -159,8 +154,7 @@ def convert_date(obj): def get_dates(thing, date_field_prefix=None): - """ - given a dict like thing, return the date items + """Given a dict like thing, return the date items. Parameters ---------- @@ -348,10 +342,9 @@ def get_due_date(thing): def is_current(thing, now=None): - """ - given a thing with dates, returns true if the thing is current - looks for begin_ and end_ date things (date, year, month, day), or just - the date things themselves. e.g., begin_date, end_month, month, and so on. + """Given a thing with dates, returns true if the thing is current looks for + begin_ and end_ date things (date, year, month, day), or just the date + things themselves. e.g., begin_date, end_month, month, and so on. Parameters ---------- @@ -363,7 +356,6 @@ def is_current(thing, now=None): Returns ------- True if the thing is current and false otherwise - """ if now is None: now = datetime.date.today() @@ -380,8 +372,7 @@ def is_current(thing, now=None): def has_started(thing, now=None): - """ - given a thing with dates, returns true if the thing has started + """Given a thing with dates, returns true if the thing has started. Parameters ---------- @@ -393,7 +384,6 @@ def has_started(thing, now=None): Returns ------- True if the thing has started and false otherwise - """ if not now: now = datetime.date.today() @@ -408,8 +398,7 @@ def has_started(thing, now=None): def has_finished(thing, now=None): - """ - given a thing with dates, returns true if the thing has finished + """Given a thing with dates, returns true if the thing has finished. Parameters ---------- @@ -421,7 +410,6 @@ def has_finished(thing, now=None): Returns ------- True if the thing has finished and false otherwise - """ if not now: now = datetime.date.today() @@ -435,8 +423,8 @@ def has_finished(thing, now=None): def is_before(thing, now=None): - """ - given a thing with a date, returns true if the thing is before the input date + """Given a thing with a date, returns true if the thing is before the input + date. Parameters ---------- @@ -448,7 +436,6 @@ def is_before(thing, now=None): Returns ------- True if the thing is before the date - """ if not now: now = datetime.date.today() @@ -463,8 +450,8 @@ def is_before(thing, now=None): def is_after(thing, now=None): - """ - given a thing with a date, returns true if the thing is after the input date + """Given a thing with a date, returns true if the thing is after the input + date. Parameters ---------- @@ -476,7 +463,6 @@ def is_after(thing, now=None): Returns ------- True if the thing is after the date - """ if not now: now = datetime.date.today() @@ -491,8 +477,8 @@ def is_after(thing, now=None): def is_between(thing, start=None, end=None): - """ - given a thing with a date, returns true if the thing is between the start and end date + """Given a thing with a date, returns true if the thing is between the + start and end date. Parameters ---------- @@ -506,7 +492,6 @@ def is_between(thing, start=None, end=None): Returns ------- True if the thing is between the start and end - """ if not start: start = datetime.date.today() diff --git a/src/regolith/deploy.py b/src/regolith/deploy.py index 8cb196238..9f813ddfc 100644 --- a/src/regolith/deploy.py +++ b/src/regolith/deploy.py @@ -22,7 +22,7 @@ def ensure_deploy_dir(rc): def deploy_git(rc, name, url, src="html", dst=None): - """Loads a git database""" + """Loads a git database.""" targetdir = os.path.join(rc.deploydir, name) # get or update the database if os.path.isdir(targetdir): @@ -61,7 +61,7 @@ def deploy_git(rc, name, url, src="html", dst=None): def deploy_hg(rc, name, url, src="html", dst=None): - """Loads an hg database""" + """Loads an hg database.""" if hglib is None: raise ImportError("hglib") targetdir = os.path.join(rc.deploydir, name) @@ -86,7 +86,7 @@ def deploy_hg(rc, name, url, src="html", dst=None): def deploy(rc, name, url, src="html", dst=None): - """Deploys a target""" + """Deploys a target.""" ensure_deploy_dir(rc) if url.startswith("git") or url.endswith(".git"): deploy_git(rc, name, url, src=src, dst=dst) diff --git a/src/regolith/emailer.py b/src/regolith/emailer.py index 0197827b3..6ae788a21 100644 --- a/src/regolith/emailer.py +++ b/src/regolith/emailer.py @@ -1,4 +1,4 @@ -"""Emails people via SMTP""" +"""Emails people via SMTP.""" import os import smtplib @@ -39,9 +39,10 @@ def attach_pdf(filename): def make_message(rc, to, subject="", body="", attachments=()): - """Creates an email following the appropriate format. The body kwarg - may be a string of restructured text. Attachments is a list of filenames - to attach. + """Creates an email following the appropriate format. + + The body kwarg may be a string of restructured text. Attachments is + a list of filenames to attach. """ msg = MIMEMultipart("alternative") plain = MIMEText(body, "plain") @@ -143,7 +144,7 @@ def class_email(rc): def list_email(rc): - """List class emails""" + """List class emails.""" course = rc.client.find_one(rc.db, "courses", {"_id": rc.course_ids}) student_ids = set(course["students"]) students = rc.client[rc.db]["students"] @@ -161,7 +162,7 @@ def list_email(rc): def emailer(rc): - """Constructs and sends out emails""" + """Constructs and sends out emails.""" constructor = EMAIL_CONSTRUCTORS[rc.email_target] emails = constructor(rc) if emails is None: diff --git a/src/regolith/fsclient.py b/src/regolith/fsclient.py index 37336ae82..0bb2502f7 100644 --- a/src/regolith/fsclient.py +++ b/src/regolith/fsclient.py @@ -37,7 +37,7 @@ def __exit__(self, type, value, traceback): def _rec_re_type(i): - """Destroy this when ruamel.yaml supports basetypes again""" + """Destroy this when ruamel.yaml supports basetypes again.""" if type(i) in YAML_BASE_MAP: base = YAML_BASE_MAP[type(i)]() if isinstance(base, dict): @@ -187,14 +187,14 @@ def load_database(self, db): self.load_yaml(db, dbpath) def dump_json(self, docs, collname, dbpath): - """Dumps json docs and returns filename""" + """Dumps json docs and returns filename.""" f = os.path.join(dbpath, collname + ".json") dump_json(f, docs) filename = os.path.split(f)[-1] return filename def dump_yaml(self, docs, collname, dbpath): - """Dumps json docs and returns filename""" + """Dumps json docs and returns filename.""" f = os.path.join(dbpath, collname + self._collexts.get(collname, ".yaml")) inst = self._yamlinsts.get((dbpath, collname), None) dump_yaml(f, docs, inst=inst) @@ -250,7 +250,7 @@ def insert_many(self, dbname, collname, docs): coll[doc["_id"]] = doc def delete_one(self, dbname, collname, doc): - """Removes a single document from a collection""" + """Removes a single document from a collection.""" coll = self.dbs[dbname][collname] del coll[doc["_id"]] diff --git a/src/regolith/helper_connect_main.py b/src/regolith/helper_connect_main.py index b537e2133..f4562b691 100644 --- a/src/regolith/helper_connect_main.py +++ b/src/regolith/helper_connect_main.py @@ -1,4 +1,4 @@ -"""The main CLI for regolith""" +"""The main CLI for regolith.""" from __future__ import print_function diff --git a/src/regolith/helper_gui_main.py b/src/regolith/helper_gui_main.py index 619693ab3..cbd5abf3e 100644 --- a/src/regolith/helper_gui_main.py +++ b/src/regolith/helper_gui_main.py @@ -1,4 +1,4 @@ -"""The main CLI for regolith""" +"""The main CLI for regolith.""" from __future__ import print_function diff --git a/src/regolith/helpers/a_expensehelper.py b/src/regolith/helpers/a_expensehelper.py index 4f41a1065..799f8e8b0 100644 --- a/src/regolith/helpers/a_expensehelper.py +++ b/src/regolith/helpers/a_expensehelper.py @@ -1,6 +1,4 @@ -""" -Helper to add expenses. -""" +"""Helper to add expenses.""" import datetime as dt @@ -19,8 +17,7 @@ def expense_constructor(key, begin_date, end_date, rc): - """ - constructs a document with default fields for an expense + """Constructs a document with default fields for an expense. Parameters ---------- @@ -48,7 +45,6 @@ def expense_constructor(key, begin_date, end_date, rc): Returns ------- The constructed expense document - """ pdoc = {} pdoc.update( @@ -255,7 +251,7 @@ class ExpenseAdderHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}", "people", "groups"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_grppub_readlisthelper.py b/src/regolith/helpers/a_grppub_readlisthelper.py index 175b64efd..4090a21cf 100644 --- a/src/regolith/helpers/a_grppub_readlisthelper.py +++ b/src/regolith/helpers/a_grppub_readlisthelper.py @@ -52,13 +52,13 @@ def subparser(subpi): class GrpPubReadListAdderHelper(DbHelperBase): - """Build a helper""" + """Build a helper.""" btype = "a_grppub_readlist" needed_colls = ["citations", "reading_lists"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_manurevhelper.py b/src/regolith/helpers/a_manurevhelper.py index 9fb0088b2..4c4099a08 100644 --- a/src/regolith/helpers/a_manurevhelper.py +++ b/src/regolith/helpers/a_manurevhelper.py @@ -43,7 +43,7 @@ class ManuRevAdderHelper(DbHelperBase): needed_colls = ["refereeReports"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_presentationhelper.py b/src/regolith/helpers/a_presentationhelper.py index e8134d286..fc8552d17 100644 --- a/src/regolith/helpers/a_presentationhelper.py +++ b/src/regolith/helpers/a_presentationhelper.py @@ -125,14 +125,14 @@ def subparser(subpi): class PresentationAdderHelper(DbHelperBase): - """Helper for adding presentations" """ + """Helper for adding presentations".""" # btype must be the same as helper target in helper.py btype = "a_presentation" needed_colls = [f"{TARGET_COLL}", "groups", "people", "expenses"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_projectumhelper.py b/src/regolith/helpers/a_projectumhelper.py index c8937e47e..ab00b43bb 100644 --- a/src/regolith/helpers/a_projectumhelper.py +++ b/src/regolith/helpers/a_projectumhelper.py @@ -1,7 +1,7 @@ """Helper for adding a projectum to the projecta collection. -Projecta are small bite-sized project quanta that typically will result in -one manuscript. +Projecta are small bite-sized project quanta that typically will result +in one manuscript. """ import datetime as dt @@ -68,8 +68,8 @@ def subparser(subpi): class ProjectumAdderHelper(DbHelperBase): """Helper for adding a projectum to the projecta collection. - Projecta are small bite-sized project quanta that typically will result in - one manuscript. + Projecta are small bite-sized project quanta that typically will + result in one manuscript. """ # btype must be the same as helper target in helper.py @@ -77,7 +77,7 @@ class ProjectumAdderHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}", "groups", "people"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_proposalhelper.py b/src/regolith/helpers/a_proposalhelper.py index 955b7347a..50e162889 100644 --- a/src/regolith/helpers/a_proposalhelper.py +++ b/src/regolith/helpers/a_proposalhelper.py @@ -106,8 +106,8 @@ def subparser(subpi): class ProposalAdderHelper(DbHelperBase): """Helper for adding a proposal to the proposals collection. - A proposal is a dictionary object describing a research or - project proposal submitted by the group. + A proposal is a dictionary object describing a research or project + proposal submitted by the group. """ # btype must be the same as helper target in helper.py @@ -115,7 +115,7 @@ class ProposalAdderHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}", "people", "groups"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_proprevhelper.py b/src/regolith/helpers/a_proprevhelper.py index 35909bbd1..7c228e3ba 100644 --- a/src/regolith/helpers/a_proprevhelper.py +++ b/src/regolith/helpers/a_proprevhelper.py @@ -36,13 +36,13 @@ def subparser(subpi): class PropRevAdderHelper(DbHelperBase): - """Build a helper""" + """Build a helper.""" btype = "a_proprev" needed_colls = ["proposalReviews"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/a_todohelper.py b/src/regolith/helpers/a_todohelper.py index 607daeccd..c3d00d57d 100644 --- a/src/regolith/helpers/a_todohelper.py +++ b/src/regolith/helpers/a_todohelper.py @@ -1,4 +1,4 @@ -"""Helper for adding a to_do task to todos.yml""" +"""Helper for adding a to_do task to todos.yml.""" import datetime as dt @@ -101,14 +101,14 @@ def subparser(subpi): class TodoAdderHelper(DbHelperBase): - """Helper for adding a todo task to todos.yml""" + """Helper for adding a todo task to todos.yml.""" # btype must be the same as helper target in helper.py btype = "a_todo" needed_colls = [f"{TARGET_COLL}", "projecta"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/attestationshelper.py b/src/regolith/helpers/attestationshelper.py index 5ad64bbc3..1c1d5fca8 100644 --- a/src/regolith/helpers/attestationshelper.py +++ b/src/regolith/helpers/attestationshelper.py @@ -45,14 +45,14 @@ def subparser(subpi): class AttestationsHelper(DbHelperBase): - """Helper for attestations""" + """Helper for attestations.""" # btype must be the same as helper target in helper.py btype = "attestation" needed_colls = ["people", "grants", "proposals", "expenses"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/basehelper.py b/src/regolith/helpers/basehelper.py index 18b8e5f09..14176918c 100644 --- a/src/regolith/helpers/basehelper.py +++ b/src/regolith/helpers/basehelper.py @@ -1,4 +1,4 @@ -"""Builder Base Classes""" +"""Builder Base Classes.""" import os from glob import glob @@ -12,7 +12,7 @@ class HelperBase(object): - """Base class for helpers""" + """Base class for helpers.""" def __init__(self, rc): self.rc = rc @@ -35,7 +35,7 @@ def __init__(self, rc): self.cmds = [] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" gtx = self.gtx gtx["len"] = len gtx["True"] = True @@ -52,7 +52,7 @@ def construct_global_ctx(self): gtx["date_to_rfc822"] = date_to_rfc822 def render(self, tname, fname, **kwargs): - """Render the template into a file using the kwargs and global context + """Render the template into a file using the kwargs and global context. Parameters ---------- @@ -74,14 +74,14 @@ def render(self, tname, fname, **kwargs): f.write(result) def hlp(self): - """run the helper, note this runs any of the commands - listed in ``self.cmds``""" + """Run the helper, note this runs any of the commands listed in + ``self.cmds``""" for cmd in self.cmds: getattr(self, cmd)() class SoutHelperBase(HelperBase): - """Base class for builders that just print to sout""" + """Base class for builders that just print to sout.""" def __init__(self, rc): super().__init__(rc) @@ -89,7 +89,7 @@ def __init__(self, rc): class DbHelperBase(HelperBase): - """Base class for builders that update databases""" + """Base class for builders that update databases.""" def __init__(self, rc): super().__init__(rc) @@ -97,7 +97,7 @@ def __init__(self, rc): class LatexHelperBase(HelperBase): - """Base class for Latex builders""" + """Base class for Latex builders.""" def __init__(self, rc): super().__init__(rc) @@ -115,11 +115,11 @@ def construct_global_ctx(self): gtx["latex_safe_url"] = latex_safe_url def run(self, cmd): - """Run command in build dir""" + """Run command in build dir.""" subprocess.run(cmd, cwd=self.bldir, check=True) def pdf(self, base): - """Compiles latex files to PDF""" + """Compiles latex files to PDF.""" if self.rc.pdf: self.run(["latex"] + LATEX_OPTS + [base + ".tex"]) self.run(["bibtex"] + [base + ".aux"]) @@ -131,7 +131,7 @@ def pdf(self, base): self.run(["dvipdf", base]) def clean(self): - """Remove files created by latex""" + """Remove files created by latex.""" postfixes = [ "*.dvi", "*.toc", diff --git a/src/regolith/helpers/f_todohelper.py b/src/regolith/helpers/f_todohelper.py index 677f92a8e..6e9a58ab4 100644 --- a/src/regolith/helpers/f_todohelper.py +++ b/src/regolith/helpers/f_todohelper.py @@ -70,7 +70,7 @@ class TodoFinisherHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/hellohelper.py b/src/regolith/helpers/hellohelper.py index 6bae5181b..8dd1ea27e 100644 --- a/src/regolith/helpers/hellohelper.py +++ b/src/regolith/helpers/hellohelper.py @@ -11,13 +11,13 @@ def subparser(subpi): class HelloHelper(SoutHelperBase): - """Build a helper""" + """Build a helper.""" btype = "hello" needed_colls = ["test"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -32,7 +32,7 @@ def sout(self): return print(f"hello {person}") def latex(self): - """Render latex template""" + """Render latex template.""" for rev in self.gtx["refereeReports"]: outname = "{}_{}".format(_id_key(rev), rev["reviewer"]) self.render( diff --git a/src/regolith/helpers/l_abstracthelper.py b/src/regolith/helpers/l_abstracthelper.py index 07151cfc3..8b87d5b4d 100644 --- a/src/regolith/helpers/l_abstracthelper.py +++ b/src/regolith/helpers/l_abstracthelper.py @@ -34,14 +34,15 @@ def subparser(subpi): class AbstractListerHelper(SoutHelperBase): - """Helper for finding and listing abstracts from the presentations.yml file""" + """Helper for finding and listing abstracts from the presentations.yml + file.""" # btype must be the same as helper target in helper.py btype = HELPER_TARGET needed_colls = [f"{TARGET_COLL}", "people", "contacts", "institutions"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_contactshelper.py b/src/regolith/helpers/l_contactshelper.py index 96fe47ae6..cb98b0658 100644 --- a/src/regolith/helpers/l_contactshelper.py +++ b/src/regolith/helpers/l_contactshelper.py @@ -1,4 +1,5 @@ """Helper for finding and listing contacts from the contacts.yml database. + Prints name, institution, and email (if applicable) of the contact. """ @@ -63,14 +64,14 @@ def subparser(subpi): class ContactsListerHelper(SoutHelperBase): - """Helper for finding and listing contacts from the contacts.yml file""" + """Helper for finding and listing contacts from the contacts.yml file.""" # btype must be the same as helper target in helper.py btype = HELPER_TARGET needed_colls = [f"{TARGET_COLL}", "institutions"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_currentappointmentshelper.py b/src/regolith/helpers/l_currentappointmentshelper.py index 94f627d8f..dcb63697e 100644 --- a/src/regolith/helpers/l_currentappointmentshelper.py +++ b/src/regolith/helpers/l_currentappointmentshelper.py @@ -27,14 +27,15 @@ def subparser(subpi): class CurrentAppointmentsListerHelper(SoutHelperBase): - """Helper for managing appointments on grants and studying the burn of grants over time.""" + """Helper for managing appointments on grants and studying the burn of + grants over time.""" # btype must be the same as helper target in helper.py btype = "currentappointments" needed_colls = ["people", "grants", "proposals"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_generalhelper.py b/src/regolith/helpers/l_generalhelper.py index 9d3adb6a5..f659558f9 100644 --- a/src/regolith/helpers/l_generalhelper.py +++ b/src/regolith/helpers/l_generalhelper.py @@ -37,7 +37,7 @@ class GeneralListerHelper(SoutHelperBase): btype = HELPER_TARGET def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_grantshelper.py b/src/regolith/helpers/l_grantshelper.py index 63ea95e9d..280cd1b94 100644 --- a/src/regolith/helpers/l_grantshelper.py +++ b/src/regolith/helpers/l_grantshelper.py @@ -60,7 +60,7 @@ class GrantsListerHelper(SoutHelperBase): needed_colls = [f"{TARGET_COLL}", "proposals"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_membershelper.py b/src/regolith/helpers/l_membershelper.py index 1506054d8..0263dd107 100644 --- a/src/regolith/helpers/l_membershelper.py +++ b/src/regolith/helpers/l_membershelper.py @@ -41,7 +41,7 @@ class MembersListerHelper(SoutHelperBase): needed_colls = [f"{TARGET_COLL}", "institutions", "groups"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_milestoneshelper.py b/src/regolith/helpers/l_milestoneshelper.py index 441189785..6a942a652 100644 --- a/src/regolith/helpers/l_milestoneshelper.py +++ b/src/regolith/helpers/l_milestoneshelper.py @@ -1,7 +1,7 @@ """Helper for listing upcoming (and past) projectum milestones. -Projecta are small bite-sized project quanta that typically will result in -one manuscript. +Projecta are small bite-sized project quanta that typically will result +in one manuscript. """ from gooey import GooeyParser @@ -93,8 +93,8 @@ def subparser(subpi): class MilestonesListerHelper(SoutHelperBase): """Helper for listing upcoming (and past) projectum milestones. - Projecta are small bite-sized project quanta that typically will result in - one manuscript. + Projecta are small bite-sized project quanta that typically will + result in one manuscript. """ # btype must be the same as helper target in helper.py @@ -102,7 +102,7 @@ class MilestonesListerHelper(SoutHelperBase): needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_progressreporthelper.py b/src/regolith/helpers/l_progressreporthelper.py index b9c23b503..9c9db986c 100644 --- a/src/regolith/helpers/l_progressreporthelper.py +++ b/src/regolith/helpers/l_progressreporthelper.py @@ -1,7 +1,7 @@ """Helper for listing a summary of finished prums and progress on open prums. -Projecta are small bite-sized project quanta that typically will result in -one manuscript. +Projecta are small bite-sized project quanta that typically will result +in one manuscript. """ import datetime @@ -53,8 +53,8 @@ def subparser(subpi): class ProgressReportHelper(SoutHelperBase): """Helper for listing upcoming (and past) projectum milestones. - Projecta are small bite-sized project quanta that typically will result in - one manuscript. + Projecta are small bite-sized project quanta that typically will + result in one manuscript. """ # btype must be the same as helper target in helper.py @@ -62,7 +62,7 @@ class ProgressReportHelper(SoutHelperBase): needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_projectahelper.py b/src/regolith/helpers/l_projectahelper.py index ef2452d5a..d377d5a6e 100644 --- a/src/regolith/helpers/l_projectahelper.py +++ b/src/regolith/helpers/l_projectahelper.py @@ -1,7 +1,7 @@ """Helper for listing upcoming (and past) projectum milestones. -Projecta are small bite-sized project quanta that typically will result in -one manuscript. +Projecta are small bite-sized project quanta that typically will result +in one manuscript. """ import datetime as dt @@ -99,8 +99,8 @@ def subparser(subpi): class ProjectaListerHelper(SoutHelperBase): """Helper for listing upcoming (and past) projectum milestones. - Projecta are small bite-sized project quanta that typically will result in - one manuscript. + Projecta are small bite-sized project quanta that typically will + result in one manuscript. """ # btype must be the same as helper target in helper.py @@ -108,7 +108,7 @@ class ProjectaListerHelper(SoutHelperBase): needed_colls = [f"{TARGET_COLL}", "people"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/l_todohelper.py b/src/regolith/helpers/l_todohelper.py index adf8a1123..87bac8c57 100644 --- a/src/regolith/helpers/l_todohelper.py +++ b/src/regolith/helpers/l_todohelper.py @@ -1,6 +1,8 @@ """Helper for listing the to-do tasks. -Tasks are gathered from people.yml, milestones, and group meeting actions.""" +Tasks are gathered from people.yml, milestones, and group meeting +actions. +""" import datetime as dt import math @@ -94,14 +96,16 @@ def subparser(subpi): class TodoListerHelper(SoutHelperBase): """Helper for listing the to-do tasks. - Tasks are gathered from people.yml, milestones, and group meeting actions.""" + Tasks are gathered from people.yml, milestones, and group meeting + actions. + """ # btype must be the same as helper target in helper.py btype = HELPER_TARGET needed_colls = [f"{TARGET_COLL}", "refereeReports", "proposalReviews"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc @@ -248,7 +252,7 @@ def sout(self): def _format_todos(todo, today): - """datify dates, set orders etc and update to-do items in place + """Datify dates, set orders etc and update to-do items in place. Parameters ---------- @@ -258,7 +262,6 @@ def _format_todos(todo, today): Returns ------- nothing - """ if isinstance(todo["due_date"], str): todo["due_date"] = date_parser.parse(todo["due_date"]).date() diff --git a/src/regolith/helpers/makeappointmentshelper.py b/src/regolith/helpers/makeappointmentshelper.py index 98fcad15c..72a8017a4 100644 --- a/src/regolith/helpers/makeappointmentshelper.py +++ b/src/regolith/helpers/makeappointmentshelper.py @@ -128,14 +128,15 @@ def plotter(datearray, student=None, pd=None, ss=None, title=None): class MakeAppointmentsHelper(SoutHelperBase): - """Helper for managing appointments on grants and studying the burn of grants over time.""" + """Helper for managing appointments on grants and studying the burn of + grants over time.""" # btype must be the same as helper target in helper.py btype = HELPER_TARGET needed_colls = [f"{TARGET_COLL}", "grants", "proposals"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/reimbstatushelper.py b/src/regolith/helpers/reimbstatushelper.py index efd11fa1a..5780ab1aa 100644 --- a/src/regolith/helpers/reimbstatushelper.py +++ b/src/regolith/helpers/reimbstatushelper.py @@ -14,14 +14,14 @@ def subparser(subpi): class ReimbstatusHelper(SoutHelperBase): - """Helper for reimbstatus""" + """Helper for reimbstatus.""" # btype must be the same as helper target in helper.py btype = "reimbstatus" needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/u_contacthelper.py b/src/regolith/helpers/u_contacthelper.py index 619be25ee..bfa62d409 100644 --- a/src/regolith/helpers/u_contacthelper.py +++ b/src/regolith/helpers/u_contacthelper.py @@ -78,7 +78,7 @@ class ContactUpdaterHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/u_finishprumhelper.py b/src/regolith/helpers/u_finishprumhelper.py index dd96078f5..07efc7993 100644 --- a/src/regolith/helpers/u_finishprumhelper.py +++ b/src/regolith/helpers/u_finishprumhelper.py @@ -1,4 +1,4 @@ -"""Helper for finishing prum in the projecta collection""" +"""Helper for finishing prum in the projecta collection.""" import datetime as dt @@ -31,16 +31,14 @@ def subparser(subpi): class FinishprumUpdaterHelper(DbHelperBase): - """ - Helper for finishing prum in the projecta collection - """ + """Helper for finishing prum in the projecta collection.""" # btype must be the same as helper target in helper.py btype = "f_prum" needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/u_institutionshelper.py b/src/regolith/helpers/u_institutionshelper.py index 6b809dc0b..5f94cac0b 100644 --- a/src/regolith/helpers/u_institutionshelper.py +++ b/src/regolith/helpers/u_institutionshelper.py @@ -1,6 +1,4 @@ -""" -Helper for updating/adding to the projecta collection. -""" +"""Helper for updating/adding to the projecta collection.""" import datetime as dt import uuid @@ -70,16 +68,14 @@ def subparser(subpi): class InstitutionsUpdaterHelper(DbHelperBase): - """ - Helper for updating/adding to the projecta collection. - """ + """Helper for updating/adding to the projecta collection.""" # btype must be the same as helper target in helper.py btype = "u_institution" needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/u_logurlhelper.py b/src/regolith/helpers/u_logurlhelper.py index d973770be..986ed8c69 100644 --- a/src/regolith/helpers/u_logurlhelper.py +++ b/src/regolith/helpers/u_logurlhelper.py @@ -1,6 +1,5 @@ -"""Helper for updating a projectum's log_url -Log_urls are the google doc links to a projectum's Projectum Agenda Log -""" +"""Helper for updating a projectum's log_url Log_urls are the google doc links +to a projectum's Projectum Agenda Log.""" from regolith.fsclient import _id_key from regolith.helpers.basehelper import DbHelperBase @@ -31,16 +30,15 @@ def subparser(subpi): class LogUrlUpdaterHelper(DbHelperBase): - """ - Update a projectum's Log_url, will add a new Log_URL if one doesn't yet exist - """ + """Update a projectum's Log_url, will add a new Log_URL if one doesn't yet + exist.""" # btype must be the same as helper target in helper.py btype = "u_logurl" needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/u_milestonehelper.py b/src/regolith/helpers/u_milestonehelper.py index 56ffe4388..0d55afffc 100644 --- a/src/regolith/helpers/u_milestonehelper.py +++ b/src/regolith/helpers/u_milestonehelper.py @@ -1,6 +1,7 @@ """Helper for updating milestones to the projecta collection. -It can update the status, type, and due date of a projectum. -It can add a new milestone to the projecta collection. + +It can update the status, type, and due date of a projectum. It can add +a new milestone to the projecta collection. """ import datetime as dt @@ -76,7 +77,7 @@ class MilestoneUpdaterHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/u_todohelper.py b/src/regolith/helpers/u_todohelper.py index ca9345b34..4fc29d5b9 100644 --- a/src/regolith/helpers/u_todohelper.py +++ b/src/regolith/helpers/u_todohelper.py @@ -123,7 +123,7 @@ class TodoUpdaterHelper(DbHelperBase): needed_colls = [f"{TARGET_COLL}"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/helpers/v_meetingshelper.py b/src/regolith/helpers/v_meetingshelper.py index 7d34d63d2..82cfd133b 100644 --- a/src/regolith/helpers/v_meetingshelper.py +++ b/src/regolith/helpers/v_meetingshelper.py @@ -1,4 +1,4 @@ -"""Validator for meetings""" +"""Validator for meetings.""" import datetime as dt @@ -16,14 +16,14 @@ def subparser(subpi): class MeetingsValidatorHelper(SoutHelperBase): - """Helper for validating the entries of the meetings.yml file""" + """Helper for validating the entries of the meetings.yml file.""" # btype must be the same as helper target in helper.py btype = HELPER_TARGET needed_colls = [f"{TARGET_COLL}", "institutions"] def construct_global_ctx(self): - """Constructs the global context""" + """Constructs the global context.""" super().construct_global_ctx() gtx = self.gtx rc = self.rc diff --git a/src/regolith/interact.py b/src/regolith/interact.py index 8de804b1e..ce3278873 100644 --- a/src/regolith/interact.py +++ b/src/regolith/interact.py @@ -1,6 +1,4 @@ -""" -Loads the dbs for interactive sessions -""" +"""Loads the dbs for interactive sessions.""" from regolith.runcontrol import DEFAULT_RC, connect_db, filter_databases, load_rcfile diff --git a/src/regolith/main.py b/src/regolith/main.py index ac2eeee35..d8a6e0120 100644 --- a/src/regolith/main.py +++ b/src/regolith/main.py @@ -1,4 +1,4 @@ -"""The main CLI for regolith""" +"""The main CLI for regolith.""" from __future__ import print_function diff --git a/src/regolith/mongoclient.py b/src/regolith/mongoclient.py index 140bbc145..a9a4e8bab 100644 --- a/src/regolith/mongoclient.py +++ b/src/regolith/mongoclient.py @@ -1,6 +1,9 @@ """Client interface for MongoDB. -Maintained such that only pymongo is necessary when using helper/builders, and additional command-line tools -are necessary to install for maintenance tasks, such as fs-to-mongo.""" + +Maintained such that only pymongo is necessary when using +helper/builders, and additional command-line tools are necessary to +install for maintenance tasks, such as fs-to-mongo. +""" import datetime import itertools @@ -176,10 +179,10 @@ def doc_cleanup(doc: dict): def bson_cleanup(doc: dict): - """ - This method should be used prior to updating or adding a document to a collection in mongo. Specifically, this - replaces all periods in keys and _id value with a blank, and changes datetime.date to an iso string. It does so - recursively for nested dictionaries. + """This method should be used prior to updating or adding a document to a + collection in mongo. Specifically, this replaces all periods in keys and + _id value with a blank, and changes datetime.date to an iso string. It does + so recursively for nested dictionaries. Parameters ---------- @@ -188,13 +191,11 @@ def bson_cleanup(doc: dict): Returns ------- doc - """ def change_keys_id_and_date(obj, convert): - """ - Recursively goes through the dictionary obj and replaces keys with the convert function. - """ + """Recursively goes through the dictionary obj and replaces keys with + the convert function.""" if isinstance(obj, datetime.date): # Mongo cannot handle datetime.date format, # but we have infrastructure to handle iso date strings present @@ -270,8 +271,7 @@ def _startserver(self): def is_alive(self): """Returns whether or not the client is alive and available to - send/receive data. - """ + send/receive data.""" if self.client is None: return False elif ON_PYMONGO_V2: @@ -301,7 +301,7 @@ def is_alive(self): return False def open(self): - """Opens the database client""" + """Opens the database client.""" if self.closed: rc = self.rc mongo_dbs_filter = filter( @@ -523,7 +523,7 @@ def insert_many(self, dbname, collname, docs): return coll.insert_many(docs) def delete_one(self, dbname, collname, doc): - """Removes a single document from a collection""" + """Removes a single document from a collection.""" coll = self.client[dbname][collname] doc = doc_cleanup(doc) if ON_PYMONGO_V2: diff --git a/src/regolith/runcontrol.py b/src/regolith/runcontrol.py index 51a3fa5f7..a70e50d1e 100644 --- a/src/regolith/runcontrol.py +++ b/src/regolith/runcontrol.py @@ -1,4 +1,4 @@ -"""Run Control object for regolith""" +"""Run Control object for regolith.""" from __future__ import print_function @@ -33,7 +33,8 @@ def ensuredirs(f): def touch(filename): - """Opens a file and updates the mtime, like the posix command of the same name.""" + """Opens a file and updates the mtime, like the posix command of the same + name.""" with io.open(filename, "a"): os.utime(filename, None) @@ -51,23 +52,24 @@ def exec_file(filename, glb=None, loc=None): class NotSpecifiedType(object): - """A helper class singleton for run control meaning that a 'real' value - has not been given.""" + """A helper class singleton for run control meaning that a 'real' value has + not been given.""" def __repr__(self): return "NotSpecified" NotSpecified = NotSpecifiedType() -"""A helper class singleton for run control meaning that a 'real' value -has not been given. -""" +"""A helper class singleton for run control meaning that a 'real' value has not +been given.""" class RunControl(object): - """A composable configuration class. Unlike argparse.Namespace, - this keeps the object dictionary (__dict__) separate from the run - control attributes dictionary (_dict). + """A composable configuration class. + + Unlike argparse.Namespace, this keeps the object dictionary + (__dict__) separate from the run control attributes dictionary + (_dict). """ def __init__(self, _updaters=None, _validators=None, **kwargs): @@ -160,10 +162,12 @@ def __copy__(self): return type(self)(_updaters=self._updaters, _validators=self._validators, **self._dict) def _update(self, other): - """Updates the rc with values from another mapping. If this rc has - if a key is in self, other, and self._updaters, then the updaters - value is called to perform the update. This function should return - a copy to be safe and not update in-place. + """Updates the rc with values from another mapping. + + If this rc has if a key is in self, other, and self._updaters, + then the updaters value is called to perform the update. This + function should return a copy to be safe and not update in- + place. """ if hasattr(other, "_dict"): other = other._dict @@ -267,8 +271,7 @@ def filter_databases(rc): def connect_db(rc, colls=None): - """ - Load up the db's + """Load up the db's. Parameters ---------- diff --git a/src/regolith/schemas.py b/src/regolith/schemas.py index b4a93ffe1..ea5dff9be 100644 --- a/src/regolith/schemas.py +++ b/src/regolith/schemas.py @@ -1,4 +1,4 @@ -"""Database schemas, examples, and tools""" +"""Database schemas, examples, and tools.""" import copy import json @@ -170,16 +170,18 @@ def load_exemplars(): class NoDescriptionValidator(Validator): def _validate_description(self, description, field, value): - """Don't validate descriptions + """Don't validate descriptions. - The rule's arguments are validated against this schema: - {'type': 'string'}""" + The rule's arguments are validated against this schema: {'type': + 'string'} + """ if False: pass def _validate_eallowed(self, eallowed, field, value): - """Test if value is in list - The rule's arguments are validated against this schema: + """Test if value is in list The rule's arguments are validated against + this schema: + {'type': 'list'} """ if value not in eallowed: @@ -191,7 +193,7 @@ def _validate_eallowed(self, eallowed, field, value): def validate(coll, record, schemas): - """Validate a record for a given db + """Validate a record for a given db. Parameters ---------- @@ -208,7 +210,6 @@ def validate(coll, record, schemas): True is valid errors: dict The errors encountered (if any) - """ if coll in schemas: schema = copy.deepcopy(schemas[coll]) diff --git a/src/regolith/sorters.py b/src/regolith/sorters.py index a9305ae48..4d52f9987 100644 --- a/src/regolith/sorters.py +++ b/src/regolith/sorters.py @@ -16,13 +16,13 @@ def doc_date_key(document): Returns ------- the float serialization of the date information in the document - """ return date_to_float(document.get("year", 1970), document.get("month", "jan")) def doc_date_key_high(document): - """Convert a dict of highest Datetime object to float serialization of date info. + """Convert a dict of highest Datetime object to float serialization of date + info. Parameters ---------- @@ -32,13 +32,13 @@ def doc_date_key_high(document): Returns ------- the float serialization of the end date information in the document - """ return date_to_float(document.get("year", 1970), document.get("month", "dec")) def ene_date_key(document): - """Convert a dict of ene Datetime object to float serialization of date info. + """Convert a dict of ene Datetime object to float serialization of date + info. Parameters ---------- @@ -48,7 +48,6 @@ def ene_date_key(document): Returns ------- the float serialization of the date information in the document - """ return date_to_float(document.get("end_year", 4242), document.get("end_month", "dec")) @@ -64,7 +63,6 @@ def category_val(document): Returns ------- The string of the category item. - """ return document.get("category", "") @@ -80,13 +78,12 @@ def level_val(document): Returns ------- The string representing the level. - """ return document.get("level", "") def id_key(document): - """Convert the id-key of a document into a string + """Convert the id-key of a document into a string. Parameters ---------- @@ -96,7 +93,6 @@ def id_key(document): Returns ------- The string of the _id - """ return document.get("_id", "") diff --git a/src/regolith/storage.py b/src/regolith/storage.py index 22686f5e1..961a97bec 100644 --- a/src/regolith/storage.py +++ b/src/regolith/storage.py @@ -123,7 +123,7 @@ def push(store, path): class StorageClient(object): - """Interface to the storage system""" + """Interface to the storage system.""" def __init__(self, rc, store, path): self.rc = rc @@ -139,7 +139,7 @@ def copydoc(self, doc): return dst def retrieve(self, file_name): - """Get file from the store + """Get file from the store. Parameters ---------- @@ -165,7 +165,7 @@ def retrieve(self, file_name): @contextmanager def store_client(rc): - """Context manager for file storage + """Context manager for file storage. Parameters ---------- diff --git a/src/regolith/stylers.py b/src/regolith/stylers.py index 9435d7fe5..ccba0d0ea 100644 --- a/src/regolith/stylers.py +++ b/src/regolith/stylers.py @@ -1,4 +1,4 @@ -"""A collection of python stylers""" +"""A collection of python stylers.""" import re @@ -33,7 +33,7 @@ def sentencecase(sentence): - """returns a sentence in sentencecase but with text in braces preserved + """Returns a sentence in sentencecase but with text in braces preserved. Parameters ---------- diff --git a/src/regolith/tools.py b/src/regolith/tools.py index cbcab90b9..71df186b6 100644 --- a/src/regolith/tools.py +++ b/src/regolith/tools.py @@ -1,4 +1,7 @@ -"""Misc. regolith tools.""" +"""Misc. + +regolith tools. +""" import email.utils import os @@ -72,8 +75,8 @@ def dbpathname(db, rc): def fallback(cond, backup): - """Decorator for returning the object if cond is true and a backup if - cond is false.""" + """Decorator for returning the object if cond is true and a backup if cond + is false.""" def dec(obj): return obj if cond else backup @@ -279,7 +282,7 @@ def filter_projects(projects, people, reverse=False, active=True, group=None, pt def filter_grants(input_grants, names, pi=True, reverse=True, multi_pi=False): - """Filter grants by those involved + """Filter grants by those involved. Parameters ---------- @@ -331,7 +334,7 @@ def filter_grants(input_grants, names, pi=True, reverse=True, multi_pi=False): def filter_employment_for_advisees(peoplecoll, begin_period, status, advisor, now=None): - """Filter people to get advisees since begin_period + """Filter people to get advisees since begin_period. Parameters ---------- @@ -771,7 +774,7 @@ def awards( since=None, before=None, ): - """Make sorted awards and honors + """Make sorted awards and honors. Parameters ---------- @@ -781,7 +784,6 @@ def awards( The begin date to filter from before : date. Optional, default is None The end date to filter for. None does not apply this filter - """ if not since: since = date(1500, 1, 1) @@ -826,7 +828,7 @@ def latex_safe_url(s): def latex_safe(s, url_check=True, wrapper="url"): - """Make string latex safe + """Make string latex safe. Parameters ---------- @@ -854,7 +856,7 @@ def latex_safe(s, url_check=True, wrapper="url"): def make_bibtex_file(pubs, pid, person_dir="."): - """Make a bibtex file given the publications + """Make a bibtex file given the publications. Parameters ---------- @@ -900,7 +902,7 @@ def make_bibtex_file(pubs, pid, person_dir="."): def document_by_value(documents, address, value): - """Get a specific document by one of its values + """Get a specific document by one of its values. Parameters ---------- @@ -928,7 +930,7 @@ def document_by_value(documents, address, value): def fuzzy_retrieval(documents, sources, value, case_sensitive=True): """Retrieve a document from the documents where value is compared against - multiple potential sources + multiple potential sources. Parameters ---------- @@ -952,7 +954,6 @@ def fuzzy_retrieval(documents, sources, value, case_sensitive=True): This would get the person entry for which either the alias or the name was ``pi_name``. - """ for doc in documents: returns = [] @@ -972,7 +973,7 @@ def fuzzy_retrieval(documents, sources, value, case_sensitive=True): def number_suffix(number): - """returns the suffix that adjectivises a number (st, nd, rd, th) + """Returns the suffix that adjectivises a number (st, nd, rd, th) Parameters --------- @@ -995,7 +996,7 @@ def number_suffix(number): def dereference_institution(input_record, institutions, verbose=False): """Tool for replacing placeholders for institutions with the actual - institution data. Note that the replacement is done inplace + institution data. Note that the replacement is done inplace. Parameters ---------- @@ -1072,8 +1073,7 @@ def dereference_institution(input_record, institutions, verbose=False): def merge_collections_all(a, b, target_id): - """ - merge two collections into a single merged collection + """Merge two collections into a single merged collection. for keys that are in both collections, the value in b will be kept @@ -1115,8 +1115,7 @@ def merge_collections_all(a, b, target_id): def merge_collections_superior(a, b, target_id): - """ - merge two collections into a single merged collection + """Merge two collections into a single merged collection. for keys that are in both collections, the value in b will be kept @@ -1155,8 +1154,8 @@ def merge_collections_superior(a, b, target_id): def get_person_contact(name, people_coll, contacts_coll): - """ - Return a person document if found in either people or contacts collections + """Return a person document if found in either people or contacts + collections. If the person is found in the people collection this person is returned. If not found in people but found in contacts, the person found in contacts is @@ -1175,7 +1174,6 @@ def get_person_contact(name, people_coll, contacts_coll): ------- person: dict The found person document - """ people_person = fuzzy_retrieval( people_coll, @@ -1198,8 +1196,7 @@ def get_person_contact(name, people_coll, contacts_coll): def merge_collections_intersect(a, b, target_id): - """ - merge two collections such that just the intersection is returned + """Merge two collections such that just the intersection is returned. for shared keys that are in both collections, the value in b will be kept @@ -1231,9 +1228,8 @@ def merge_collections_intersect(a, b, target_id): def update_schemas(default_schema, user_schema): - """ - Merging the user schema into the default schema recursively and return the - merged schema. The default schema and user schema will not be modified + """Merging the user schema into the default schema recursively and return + the merged schema. The default schema and user schema will not be modified during the merging. Parameters @@ -1279,8 +1275,8 @@ def get_person(person_id, rc): def group(db, by): - """ - Group the document in the database according to the value of the doc[by] in db. + """Group the document in the database according to the value of the doc[by] + in db. Parameters ---------- @@ -1317,8 +1313,7 @@ def group(db, by): def get_pi_id(rc): - """ - Gets the database id of the group PI + """Gets the database id of the group PI. Parameters ---------- @@ -1329,7 +1324,6 @@ def get_pi_id(rc): Returns ------- The database '_id' of the group PI - """ groupiter = list(all_docs_from_collection(rc.client, "groups")) peoplecoll = all_docs_from_collection(rc.client, "people") @@ -1339,7 +1333,7 @@ def get_pi_id(rc): def group_member_ids(ppl_coll, grpname): - """Get a list of all group member ids + """Get a list of all group member ids. Parameters ---------- @@ -1375,8 +1369,7 @@ def group_member_ids(ppl_coll, grpname): def group_member_employment_start_end(person, grpname): - """ - Get start and end dates of group member employment + """Get start and end dates of group member employment. Parameters ---------- @@ -1389,7 +1382,6 @@ def group_member_employment_start_end(person, grpname): ------- list of dicts The employment periods, with person id, begin and end dates - """ grpmember = [] for k in ["employment"]: @@ -1415,8 +1407,8 @@ def group_member_employment_start_end(person, grpname): def compound_dict(doc, li): - """ - Recursive function that collects all the strings from a document that is a dictionary + """Recursive function that collects all the strings from a document that is + a dictionary. Parameters ---------- @@ -1429,7 +1421,6 @@ def compound_dict(doc, li): ------- list of strings The strings that make up the nested attributes of this object - """ for key in doc: res = doc.get(key) @@ -1443,8 +1434,8 @@ def compound_dict(doc, li): def compound_list(doc, li): - """ - Recursive function that collects all the strings from a document that is a list + """Recursive function that collects all the strings from a document that is + a list. Parameters ---------- @@ -1457,7 +1448,6 @@ def compound_list(doc, li): ------- list of strings The strings that make up the nested attributes of this list - """ for item in doc: if isinstance(item, dict): @@ -1471,7 +1461,7 @@ def compound_list(doc, li): def fragment_retrieval(coll, fields, fragment, case_sensitive=False): """Retrieves a list of all documents from the collection where the fragment - appears in any one of the given fields + appears in any one of the given fields. Parameters ---------- @@ -1495,7 +1485,6 @@ def fragment_retrieval(coll, fields, fragment, case_sensitive=False): This would get all people for which either the alias or the name included the substring ``pi_name``. - """ ret_list = [] @@ -1538,8 +1527,8 @@ def get_id_from_name(coll, name): def is_fully_appointed(person, begin_date, end_date): - """Checks if a collection of appointments for a person is valid and fully loaded - for a given interval of time + """Checks if a collection of appointments for a person is valid and fully + loaded for a given interval of time. Parameters ---------- @@ -1566,7 +1555,7 @@ def is_fully_appointed(person, begin_date, end_date): In this case, we have an invalid loading from 2017-06-16 to 2017-06-19 hence it would return False and print "appointment gap for aejaz from 2017-06-16 to 2017-06-19". - """ + """ if not person.get("appointments"): print("No appointments defined for this person") @@ -1614,7 +1603,7 @@ def is_fully_appointed(person, begin_date, end_date): def key_value_pair_filter(collection, arguments): """Retrieves a list of all documents from the collection where the fragment - appears in any one of the given fields + appears in any one of the given fields. Parameters ---------- @@ -1634,7 +1623,6 @@ def key_value_pair_filter(collection, arguments): This would get all people for which their name contains the string 'ab' and whose position is professor and return them - """ if len(arguments) % 2 != 0: @@ -1647,7 +1635,7 @@ def key_value_pair_filter(collection, arguments): def collection_str(collection, keys=None): """Retrieves a list of all documents from the collection where the fragment - appears in any one of the given fields + appears in any one of the given fields. Parameters ---------- @@ -1678,7 +1666,7 @@ def collection_str(collection, keys=None): def search_collection(collection, arguments, keys=None): """Retrieves a list of all documents from the collection where the fragment - appears in any one of the given fields + appears in any one of the given fields. Parameters ---------- @@ -1701,16 +1689,14 @@ def search_collection(collection, arguments, keys=None): This would get all people for which their name contains the string 'ab' and whose position is professor. It would return the name and id of the valid entries - """ collection = key_value_pair_filter(collection, arguments) return collection_str(collection, keys) def collect_appts(ppl_coll, filter_key=None, filter_value=None, begin_date=None, end_date=None): - """ - Retrieves a list of all the appointments on the given grant(s) in the given interval of time - for each person in the given people collection. + """Retrieves a list of all the appointments on the given grant(s) in the + given interval of time for each person in the given people collection. Parameters ---------- @@ -1792,9 +1778,8 @@ def collect_appts(ppl_coll, filter_key=None, filter_value=None, begin_date=None, def grant_burn(grant, appts, begin_date=None, end_date=None): - """ - Retrieves the total burn of a grant over an interval of time by integrating over all appointments - made on the grant. + """Retrieves the total burn of a grant over an interval of time by + integrating over all appointments made on the grant. Parameters ---------- @@ -1868,9 +1853,9 @@ def grant_burn(grant, appts, begin_date=None, end_date=None): def validate_meeting(meeting, date): - """ - Validates a meeting by checking is it has a journal club doi, a presentation link, and a presentation - title. This function will return nothing is the meeting is valid, otherwise it will raise a ValueError. + """Validates a meeting by checking is it has a journal club doi, a + presentation link, and a presentation title. This function will return + nothing is the meeting is valid, otherwise it will raise a ValueError. Parameters ---------- @@ -1878,7 +1863,6 @@ def validate_meeting(meeting, date): The meeting object that needs to be validated date: datetime object The date we want to use to see if a meeting has happened or not - """ meeting_date = date_parser.parse(meeting.get("_id")[3:]).date() if meeting.get("journal_club") and meeting_date < date: @@ -1891,8 +1875,7 @@ def validate_meeting(meeting, date): def print_task(task_list, stati, index=True): - """ - Print tasks in a nice format. + """Print tasks in a nice format. Parameters ---------- @@ -1902,7 +1885,6 @@ def print_task(task_list, stati, index=True): The list of task stati that will be printed index : bool Optional Default is True The bool that can suppress printing the preamble of importance, days to due and index - """ for status in stati: if f"'status': '{status}'" in str(task_list): @@ -1950,8 +1932,8 @@ def print_task(task_list, stati, index=True): def get_formatted_crossref_reference(doi): - """ - given a doi, return the full reference and the date of the reference from Crossref REST-API + """Given a doi, return the full reference and the date of the reference + from Crossref REST-API. parameters ---------- @@ -1965,7 +1947,6 @@ def get_formatted_crossref_reference(doi): ref_date datetime.date the date of the reference returns None None in the article cannot be found given the doi - """ cr = Crossref() @@ -2024,8 +2005,8 @@ def get_formatted_crossref_reference(doi): def remove_duplicate_docs(coll, key): - """ - find all docs where the target key has the same value and remove duplicates + """Find all docs where the target key has the same value and remove + duplicates. The doc found first will be kept and subsequent docs will be removed @@ -2039,7 +2020,6 @@ def remove_duplicate_docs(coll, key): return ------ The list of docs with duplicates (as described above) removed - """ values, newcoll = [], [] for doc in coll: @@ -2071,7 +2051,7 @@ def validate_doc(collection_name, doc, rc): def add_to_google_calendar(event): - """Takes a newly created event, and adds it to the user's google calendar + """Takes a newly created event, and adds it to the user's google calendar. Parameters: event - a dictionary containing the event details to be added to google calendar @@ -2115,8 +2095,8 @@ def add_to_google_calendar(event): def google_cal_auth_flow(): - """First time authentication, this function opens a window to request user consent to use google calendar API, - and then returns a token""" + """First time authentication, this function opens a window to request user + consent to use google calendar API, and then returns a token.""" tokendir = os.path.expanduser("~/.config/regolith/tokens/google_calendar_api") os.makedirs(tokendir, exist_ok=True) tokenfile = os.path.join(tokendir, "token.json") @@ -2131,7 +2111,7 @@ def google_cal_auth_flow(): def get_target_repo_info(target_repo_id, repos): - """checks if repo information is defined and valid in rc + """Checks if repo information is defined and valid in rc. Parameters: target_repo_id - string @@ -2194,7 +2174,7 @@ def get_target_repo_info(target_repo_id, repos): def get_target_token(target_token_id, tokens): - """Checks if API authentication token is defined and valid in rc + """Checks if API authentication token is defined and valid in rc. Parameters: target_token_id - string @@ -2223,7 +2203,7 @@ def get_target_token(target_token_id, tokens): def create_repo(destination_id, token_info_id, rc): - """Creates a repo at the target destination + """Creates a repo at the target destination. tries to fail gracefully if repo information and token is not defined @@ -2274,8 +2254,7 @@ def create_repo(destination_id, token_info_id, rc): def get_tags(coll): - """ - Given a collection with a tags field, returns the set of tags as a list + """Given a collection with a tags field, returns the set of tags as a list. The tags field is expected to be a string with comma or space separated tags. get_tags splits the tags and returns the set of unique tags as a list of @@ -2289,7 +2268,6 @@ def get_tags(coll): Returns ------- the set of all tags as a list - """ all_tags = [] @@ -2307,15 +2285,12 @@ def get_tags(coll): def get_uuid(): - """ - returns a uuid.uuid4 string - """ + """Returns a uuid.uuid4 string.""" return str(uuid.uuid4()) def get_appointments(person, appointments, target_grant=None): - """ - get appointments from a person from the people collection + """Get appointments from a person from the people collection. Parameters ---------- @@ -2333,7 +2308,6 @@ def get_appointments(person, appointments, target_grant=None): Returns ------- updated appointments list - """ for appt_id, appt in person.get("appointments").items(): if target_grant is None or appt.get("grant", "no_grant") == target_grant: diff --git a/src/regolith/validators.py b/src/regolith/validators.py index 8e66cf6f6..4250fd71f 100644 --- a/src/regolith/validators.py +++ b/src/regolith/validators.py @@ -12,27 +12,27 @@ def noop(x): def is_int(x): - """Tests if something is an integer""" + """Tests if something is an integer.""" return isinstance(x, int) def always_true(x): - """Returns True""" + """Returns True.""" return True def always_false(x): - """Returns False""" + """Returns False.""" return False def is_bool(x): - """Tests if something is a boolean""" + """Tests if something is a boolean.""" return isinstance(x, bool) def is_string(x): - """Tests if something is a string""" + """Tests if something is a string.""" return isinstance(x, string_types) @@ -40,7 +40,7 @@ def is_string(x): def to_bool(x): - """ "Converts to a boolean in a semantically meaningful way.""" + """"Converts to a boolean in a semantically meaningful way.""" if isinstance(x, bool): return x elif isinstance(x, string_types): @@ -66,7 +66,7 @@ def ensure_database(db): def ensure_databases(dbs): - """Ensures each dataset in a list of databases""" + """Ensures each dataset in a list of databases.""" return list(map(ensure_database, dbs)) @@ -79,7 +79,7 @@ def ensure_store(store): def ensure_stores(stores): - """Ensures each store in a list of stores""" + """Ensures each store in a list of stores.""" return list(map(ensure_store, stores)) diff --git a/src/regolith/version.py b/src/regolith/version.py index e6c7bab03..b39d99fcf 100644 --- a/src/regolith/version.py +++ b/src/regolith/version.py @@ -12,7 +12,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """Definition of __version__.""" # We do not use the other three variables, but can be added back if needed. diff --git a/tests/bootstrap_builders.py b/tests/bootstrap_builders.py index 20b797b54..3f110e525 100644 --- a/tests/bootstrap_builders.py +++ b/tests/bootstrap_builders.py @@ -63,6 +63,7 @@ def rmtree(dirname): def make_db(): """A test fixutre that creates and destroys a git repo in a temporary directory. + This will yield the path to the repo. """ cwd = os.getcwd() diff --git a/tests/conftest.py b/tests/conftest.py index 6762fd7ec..94d1119df 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,4 @@ -"""Copyright (c) 2017, Anthony Scopatz -All rights reserved.""" +"""Copyright (c) 2017, Anthony Scopatz All rights reserved.""" import json import os @@ -44,6 +43,7 @@ def user_filesystem(tmp_path): def make_db(): """A test fixutre that creates and destroys a git repo in a temporary directory. + This will yield the path to the repo. """ cwd = os.getcwd() @@ -106,6 +106,7 @@ def make_db(): def make_mongodb(): """A test fixture that creates and destroys a git repo in a temporary directory, as well as a mongo database. + This will yield the path to the repo. """ forked = False @@ -199,11 +200,12 @@ def make_mongodb(): @pytest.fixture(scope="module") def make_mixed_db(): """A test fixture that creates and destroys a git repo in a temporary - directory, as well as a mongo database. - This will yield the path to the repo. + directory, as well as a mongo database. This will yield the path to the + repo. - This specific test fixture points to a repo that mixes mongo and filesystem backends for the assignments and - abstracts test collections in EXEMPLARS respectively. + This specific test fixture points to a repo that mixes mongo and + filesystem backends for the assignments and abstracts test + collections in EXEMPLARS respectively. """ cwd = os.getcwd() forked = False @@ -313,6 +315,7 @@ def make_mixed_db(): def make_bad_db(): """A test fixutre that creates and destroys a git repo in a temporary directory. + This will yield the path to the repo. """ cwd = os.getcwd() @@ -369,11 +372,12 @@ def make_bad_db(): @pytest.fixture(scope="function") def make_fs_to_mongo_migration_db(): """A test fixture that creates and destroys a git repo in a temporary - directory, as well as a mongo database. - This will yield the path to the repo. + directory, as well as a mongo database. This will yield the path to the + repo. - This specific test fixture points to a repo that contains mongo and filesystem backends with only the - filesystem containing the exemplars. This is meant for use in migration testing. + This specific test fixture points to a repo that contains mongo and + filesystem backends with only the filesystem containing the + exemplars. This is meant for use in migration testing. """ yield from make_migration_db(True) @@ -381,11 +385,12 @@ def make_fs_to_mongo_migration_db(): @pytest.fixture(scope="function") def make_mongo_to_fs_backup_db(): """A test fixture that creates and destroys a git repo in a temporary - directory, as well as a mongo database. - This will yield the path to the repo. + directory, as well as a mongo database. This will yield the path to the + repo. - This specific test fixture points to a repo that contains mongo and filesystem backends with only the - filesystem containing the exemplars. This is meant for use in migration testing. + This specific test fixture points to a repo that contains mongo and + filesystem backends with only the filesystem containing the + exemplars. This is meant for use in migration testing. """ yield from make_migration_db(False) diff --git a/tests/test_builders.py b/tests/test_builders.py index 3fbb61809..6e9ca2626 100644 --- a/tests/test_builders.py +++ b/tests/test_builders.py @@ -38,8 +38,12 @@ def is_same(text0: str, text1: str, ignored: list): - """Compare the content of two text. If there are different words in text0 and text1 and the word in text0 - does not contain ignored substring, return False. Else return True.""" + """Compare the content of two text. + + If there are different words in text0 and text1 and the word in + text0 does not contain ignored substring, return False. Else return + True. + """ def should_ignore(word): for w in ignored: diff --git a/tests/test_validate.py b/tests/test_validate.py index 4020a2e0c..85cc3ba72 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -22,9 +22,10 @@ def test_validate_python(make_db): def test_validate_python_single_col(make_db): - """ - to see output from a failed test, comment out the code that rediriects stdout - to out and replace the assert with 'assert false'. Change it back afterwards + """To see output from a failed test, comment out the code that rediriects + stdout to out and replace the assert with 'assert false'. + + Change it back afterwards """ repo = make_db os.chdir(repo) diff --git a/tests/test_version.py b/tests/test_version.py index 0b10a139c..7c46afa91 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,10 +1,10 @@ -"""Unit tests for __version__.py -""" +"""Unit tests for __version__.py.""" import regolith def test_package_version(): - """Ensure the package version is defined and not set to the initial placeholder.""" + """Ensure the package version is defined and not set to the initial + placeholder.""" assert hasattr(regolith, "__version__") assert regolith.__version__ != "0.0.0"