Skip to content

Commit

Permalink
Add pycodestyle scripts to obs-monitor (NOAA-EMC#11)
Browse files Browse the repository at this point in the history
Added `pycodestyle_run.py` and related files (lifted from eva). Renamed
`plotObsMon `to `plotObsMon.py` so pycodestyle_run.py could pick it up.

Resolves NOAA-EMC#10

---------

Co-authored-by: Cory Martin <[email protected]>
  • Loading branch information
EdwardSafford-NOAA and CoryMartin-NOAA authored Nov 30, 2023
1 parent f2bab60 commit ba89383
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/norms.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Coding Norms
on: [push]
on: [push, pull_request]

jobs:
check_pynorms:
Expand All @@ -20,4 +20,4 @@ jobs:
- name: Run pycodestyle
run: |
cd $GITHUB_WORKSPACE/obs-monitor
pycodestyle -v --config ./.pycodestyle ./ush ./ush/plotObsMon
pycodestyle -v --config ./.pycodestyle ./ush
29 changes: 29 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

extends: default

rules:
braces:
level: warning
max-spaces-inside: 1
brackets:
level: warning
max-spaces-inside: 1
colons:
level: warning
commas:
level: warning
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
level: warning
hyphens:
level: warning
indentation:
level: warning
indent-sequences: consistent
line-length:
level: warning
allow-non-breakable-inline-mappings: true
truthy: disable
7 changes: 7 additions & 0 deletions pycodestyle.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.

[pycodestyle]
max-line-length = 100
indent-size = 4
statistics = True
26 changes: 26 additions & 0 deletions pycodestyle_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python

# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.

import unittest
import pycodestyle


# --------------------------------------------------------------------------------------------------


class TestCodeFormat(unittest.TestCase):

def test_conformance(self):
"""Test that we conform to PEP-8."""
style = pycodestyle.StyleGuide(config_file='pycodestyle.cfg')
result = style.check_files(['.'])
self.assertEqual(result.total_errors, 0, "Found code style errors (and warnings).")


# --------------------------------------------------------------------------------------------------


if __name__ == '__main__':
unittest.main()
3 changes: 2 additions & 1 deletion ush/plotObsMon → ush/plotObsMon.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def loadConfig(satname, instrument, plot, cycle_tm, cycle_interval, data_locatio
instrument = inst.get('name')

for plot in inst.get('plot_list'):
config = loadConfig(satname, instrument, plot, cycle_tm, cycle_interval, data_location)
config = loadConfig(satname, instrument, plot, cycle_tm,
cycle_interval, data_location)
plot_template = f"{config['PLOT_TEMPLATE']}.yaml"
plot_yaml = f"{config['SENSOR']}_{config['SAT']}_{plot_template}"

Expand Down

0 comments on commit ba89383

Please sign in to comment.