Skip to content

Commit

Permalink
Apply the formatting to double quotes on template repo
Browse files Browse the repository at this point in the history
  • Loading branch information
agoscinski committed Jul 24, 2024
1 parent 74e95bd commit f2f64ed
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 120 deletions.
8 changes: 4 additions & 4 deletions {{cookiecutter.plugin_name}}/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import pytest

pytest_plugins = ['aiida.manage.tests.pytest_fixtures']
pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]


@pytest.fixture(scope='function', autouse=True)
@pytest.fixture(scope="function", autouse=True)
def clear_database_auto(clear_database): # pylint: disable=unused-argument
"""Automatically clear database in between tests."""


@pytest.fixture(scope='function')
@pytest.fixture(scope="function")
def {{cookiecutter.entry_point_prefix}}_code(aiida_local_code_factory):
"""Get a {{cookiecutter.entry_point_prefix}} code."""
return aiida_local_code_factory(executable='diff', entry_point='{{cookiecutter.entry_point_prefix}}')
return aiida_local_code_factory(executable="diff", entry_point="{{cookiecutter.entry_point_prefix}}")
76 changes: 38 additions & 38 deletions {{cookiecutter.plugin_name}}/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# -- AiiDA-related setup --------------------------------------------------

# Load AiiDA profile
temp_profile = SqliteTempBackend.create_profile('temp-profile')
temp_profile = SqliteTempBackend.create_profile("temp-profile")
load_profile(temp_profile, allow_switch=True)

# -- General configuration ------------------------------------------------
Expand All @@ -34,43 +34,43 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
'sphinxcontrib.contentui',
'aiida.sphinxext',
"sphinx.ext.autodoc",
"sphinx.ext.mathjax",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinxcontrib.contentui",
"aiida.sphinxext",
]

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'aiida': ('https://aiida.readthedocs.io/projects/aiida-core/en/latest', None),
"python": ("https://docs.python.org/3", None),
"aiida": ("https://aiida.readthedocs.io/projects/aiida-core/en/latest", None),
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
# ~ master_doc = 'index'
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = '{{cookiecutter.plugin_name}}'
copyright_first_year = '{{cookiecutter.year}}'
copyright_owners = '{{cookiecutter.author}}'
project = "{{cookiecutter.plugin_name}}"
copyright_first_year = "{{cookiecutter.year}}"
copyright_owners = "{{cookiecutter.author}}"

current_year = str(time.localtime().tm_year)
copyright_year_string = (
current_year if current_year == copyright_first_year else f'{copyright_first_year}-{current_year}'
current_year if current_year == copyright_first_year else f"{copyright_first_year}-{current_year}"
)
# pylint: disable=redefined-builtin
copyright = f'{copyright_year_string}, {copyright_owners}. All rights reserved'
copyright = f"{copyright_year_string}, {copyright_owners}. All rights reserved"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -79,14 +79,14 @@
# The full version, including alpha/beta/rc tags.
release = {{cookiecutter.module_name}}.__version__
# The short X.Y version.
version = '.'.join(release.split('.')[:2])
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand All @@ -104,13 +104,13 @@
show_authors = True

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# -- Options for HTML output ----------------------------------------------

html_theme = 'furo'
html_logo = 'images/AiiDA_transparent_logo.png'
html_title = f'{{cookiecutter.plugin_name}} v{release}'
html_theme = "furo"
html_logo = "images/AiiDA_transparent_logo.png"
html_title = f"{{cookiecutter.plugin_name}} v{release}"
html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
Expand Down Expand Up @@ -167,7 +167,7 @@
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
html_use_opensearch = 'https://{{cookiecutter.plugin_name}}.readthedocs.io'
html_use_opensearch = "https://{{cookiecutter.plugin_name}}.readthedocs.io"

# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
Expand All @@ -176,13 +176,13 @@
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
html_search_language = 'en'
html_search_language = "en"

# Warnings to ignore when using the -n (nitpicky) option
# We should ignore any python built-in exception, for instance
nitpick_ignore = [
('py:class', 'Logger'),
('py:class', 'QbFields'), # Warning started to appear with aiida 2.6
("py:class", "Logger"),
("py:class", "QbFields"), # Warning started to appear with aiida 2.6
]


Expand All @@ -195,8 +195,8 @@ def run_apidoc(_):
See also https://github.com/rtfd/readthedocs.org/issues/1139
"""
source_dir = os.path.abspath(os.path.dirname(__file__))
apidoc_dir = os.path.join(source_dir, 'apidoc')
package_dir = os.path.join(source_dir, os.pardir, os.pardir, 'src', '{{cookiecutter.module_name}}')
apidoc_dir = os.path.join(source_dir, "apidoc")
package_dir = os.path.join(source_dir, os.pardir, os.pardir, "src", "{{cookiecutter.module_name}}")

# In #1139, they suggest the route below, but this ended up
# calling sphinx-build, not sphinx-apidoc
Expand All @@ -205,25 +205,25 @@ def run_apidoc(_):

import subprocess

cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
cmd_path = "sphinx-apidoc"
if hasattr(sys, "real_prefix"): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(os.path.join(sys.prefix, 'bin', 'sphinx-apidoc'))
cmd_path = os.path.abspath(os.path.join(sys.prefix, "bin", "sphinx-apidoc"))

options = [
'-o',
"-o",
apidoc_dir,
package_dir,
'--private',
'--force',
'--no-toc',
"--private",
"--force",
"--no-toc",
]

# See https://stackoverflow.com/a/30144019
env = os.environ.copy()
env['SPHINX_APIDOC_OPTIONS'] = 'members,special-members,private-members,undoc-members,show-inheritance'
env["SPHINX_APIDOC_OPTIONS"] = "members,special-members,private-members,undoc-members,show-inheritance"
subprocess.check_call([cmd_path] + options, env=env)


def setup(app):
app.connect('builder-inited', run_apidoc)
app.connect("builder-inited", run_apidoc)
34 changes: 17 additions & 17 deletions {{cookiecutter.plugin_name}}/examples/example_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from aiida.plugins import CalculationFactory, DataFactory
from {{cookiecutter.module_name}} import helpers

INPUT_DIR = path.join(path.dirname(path.realpath(__file__)), 'input_files')
INPUT_DIR = path.join(path.dirname(path.realpath(__file__)), "input_files")


def test_run({{cookiecutter.entry_point_prefix}}_code):
Expand All @@ -23,35 +23,35 @@ def test_run({{cookiecutter.entry_point_prefix}}_code):
# get code
computer = helpers.get_computer()
{{cookiecutter.entry_point_prefix}}_code = helpers.get_code(
entry_point='{{cookiecutter.entry_point_prefix}}', computer=computer
entry_point="{{cookiecutter.entry_point_prefix}}", computer=computer
)

# Prepare input parameters
diff_parameters = DataFactory('{{cookiecutter.entry_point_prefix}}')
parameters = diff_parameters({'ignore-case': True})
diff_parameters = DataFactory("{{cookiecutter.entry_point_prefix}}")
parameters = diff_parameters({"ignore-case": True})

singlefile_data = DataFactory('core.singlefile')
file1 = singlefile_data(file=path.join(INPUT_DIR, 'file1.txt'))
file2 = singlefile_data(file=path.join(INPUT_DIR, 'file2.txt'))
singlefile_data = DataFactory("core.singlefile")
file1 = singlefile_data(file=path.join(INPUT_DIR, "file1.txt"))
file2 = singlefile_data(file=path.join(INPUT_DIR, "file2.txt"))

# set up calculation
inputs = {
'code': {{cookiecutter.entry_point_prefix}}_code,
'parameters': parameters,
'file1': file1,
'file2': file2,
'metadata': {
'description': 'Test job submission with the {{cookiecutter.module_name}} plugin',
"code": {{cookiecutter.entry_point_prefix}}_code,
"parameters": parameters,
"file1": file1,
"file2": file2,
"metadata": {
"description": "Test job submission with the {{cookiecutter.module_name}} plugin",
},
}

# Note: in order to submit your calculation to the aiida daemon, do:
# from aiida.engine import submit
# future = submit(CalculationFactory('{{cookiecutter.entry_point_prefix}}'), **inputs)
result = engine.run(CalculationFactory('{{cookiecutter.entry_point_prefix}}'), **inputs)
result = engine.run(CalculationFactory("{{cookiecutter.entry_point_prefix}}"), **inputs)

computed_diff = result['{{cookiecutter.entry_point_prefix}}'].get_content()
print(f'Computed diff between files: \n{computed_diff}')
computed_diff = result["{{cookiecutter.entry_point_prefix}}"].get_content()
print(f"Computed diff between files: \n{computed_diff}")


@click.command()
Expand All @@ -69,5 +69,5 @@ def cli(code):
test_run(code)


if __name__ == '__main__':
if __name__ == "__main__":
cli() # pylint: disable=no-value-for-parameter
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
{{cookiecutter.short_description}}
"""

__version__ = '{{cookiecutter.version}}'
__version__ = "{{cookiecutter.version}}"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from aiida.orm import SinglefileData
from aiida.plugins import DataFactory

DiffParameters = DataFactory('{{cookiecutter.entry_point_prefix}}')
DiffParameters = DataFactory("{{cookiecutter.entry_point_prefix}}")


class DiffCalculation(CalcJob):
Expand All @@ -25,31 +25,31 @@ def define(cls, spec):
super().define(spec)

# set default values for AiiDA options
spec.inputs['metadata']['options']['resources'].default = {
'num_machines': 1,
'num_mpiprocs_per_machine': 1,
spec.inputs["metadata"]["options"]["resources"].default = {
"num_machines": 1,
"num_mpiprocs_per_machine": 1,
}
spec.inputs['metadata']['options']['parser_name'].default = '{{cookiecutter.entry_point_prefix}}'
spec.inputs["metadata"]["options"]["parser_name"].default = "{{cookiecutter.entry_point_prefix}}"

# new ports
spec.input('metadata.options.output_filename', valid_type=str, default='patch.diff')
spec.input("metadata.options.output_filename", valid_type=str, default="patch.diff")
spec.input(
'parameters',
"parameters",
valid_type=DiffParameters,
help='Command line parameters for diff',
help="Command line parameters for diff",
)
spec.input('file1', valid_type=SinglefileData, help='First file to be compared.')
spec.input('file2', valid_type=SinglefileData, help='Second file to be compared.')
spec.input("file1", valid_type=SinglefileData, help="First file to be compared.")
spec.input("file2", valid_type=SinglefileData, help="Second file to be compared.")
spec.output(
'{{cookiecutter.entry_point_prefix}}',
"{{cookiecutter.entry_point_prefix}}",
valid_type=SinglefileData,
help='diff between file1 and file2.',
help="diff between file1 and file2.",
)

spec.exit_code(
300,
'ERROR_MISSING_OUTPUT_FILES',
message='Calculation did not produce all expected output files.',
"ERROR_MISSING_OUTPUT_FILES",
message="Calculation did not produce all expected output files.",
)

def prepare_for_submission(self, folder):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,45 @@


# See aiida.cmdline.data entry point in setup.json
@verdi_data.group('{{cookiecutter.entry_point_prefix}}')
@verdi_data.group("{{cookiecutter.entry_point_prefix}}")
def data_cli():
"""Command line interface for {{cookiecutter.plugin_name}}"""


@data_cli.command('list')
@data_cli.command("list")
@decorators.with_dbenv()
def list_(): # pylint: disable=redefined-builtin
"""
Display all DiffParameters nodes
"""
diff_parameters = DataFactory('{{cookiecutter.entry_point_prefix}}')
diff_parameters = DataFactory("{{cookiecutter.entry_point_prefix}}")

qb = QueryBuilder()
qb.append(diff_parameters)
results = qb.all()

s = ''
s = ""
for result in results:
obj = result[0]
s += f'{obj!s}, pk: {obj.pk}\n'
s += f"{obj!s}, pk: {obj.pk}\n"
sys.stdout.write(s)


@data_cli.command('export')
@click.argument('node', metavar='IDENTIFIER', type=DataParamType())
@data_cli.command("export")
@click.argument("node", metavar="IDENTIFIER", type=DataParamType())
@click.option(
'--outfile',
'-o',
"--outfile",
"-o",
type=click.Path(dir_okay=False),
help='Write output to file (default: print to stdout).',
help="Write output to file (default: print to stdout).",
)
@decorators.with_dbenv()
def export(node, outfile):
"""Export a DiffParameters node (identified by PK, UUID or label) to plain text."""
string = str(node)

if outfile:
with open(outfile, 'w', encoding='utf8') as f:
with open(outfile, "w", encoding="utf8") as f:
f.write(string)
else:
click.echo(string)
Loading

0 comments on commit f2f64ed

Please sign in to comment.