Skip to content

Commit

Permalink
add workflows and configs
Browse files Browse the repository at this point in the history
  • Loading branch information
juleshaas committed Dec 20, 2024
1 parent 9d4253d commit ca57122
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ exclude = .git
max-line-length = 80

per-file-ignores =
./v.example.py: F821, E501
./v.example.py: E501, F821
15 changes: 12 additions & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
name: Python Flake8, black and pylint code quality check
name: Linting and code quality check

on: [push, pull_request]
on:
push:
branches:
- main
- develop
pull_request:

jobs:
lint:
uses: mundialis/github-workflows/.github/workflows/[email protected]
uses: mundialis/github-workflows/.github/workflows/linting.yml@main
with:
pylint-version: '2.17.4'
VALIDATE_JAVASCRIPT_STANDARD: false
BASH_SEVERITY: 'warning'
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ repos:
- id: check-added-large-files

- repo: https://github.com/mundialis/github-workflows
rev: 1.0.3
rev: 1.4.0
hooks:
- id: linting
39 changes: 0 additions & 39 deletions .pylintrc

This file was deleted.

50 changes: 0 additions & 50 deletions .pylintrc_allowed_to_fail

This file was deleted.

43 changes: 35 additions & 8 deletions v.example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3

"""
############################################################################
#
Expand All @@ -21,6 +22,7 @@
#
#############################################################################
"""

# %Module
# % description: {SHORT DESCRIPTION}.
# % keyword: vector
Expand Down Expand Up @@ -63,6 +65,7 @@
# import needed libraries
import atexit
import os

import grass.script as grass

# initialize global variables
Expand All @@ -80,7 +83,7 @@ def cleanup():


def main():
"""Main function of v.example"""
"""Run main function of v.example."""
global rm_vec

# print attribute values if requested
Expand Down Expand Up @@ -108,7 +111,11 @@ def main():
if column not in columns.keys():
grass.fatal(
_("Column %s does not exist in layer %s of vector %s")
% (column, layer, aoi_vector)
% (
column,
layer,
aoi_vector,
)
)

# get attribute columns as list
Expand All @@ -119,13 +126,21 @@ def main():
except ValueError:
grass.fatal(
_("Column %s does not exist in layer %s of vector %s")
% (column, layer, aoi_vector)
% (
column,
layer,
aoi_vector,
)
)

if colidx >= 0:
grass.verbose(
_("Found column %s in vector %s, layer %s")
% (column, aoi_vector, layer)
% (
column,
aoi_vector,
layer,
)
)

# query the database and table directly using information in the
Expand All @@ -135,7 +150,9 @@ def main():
driver = db_connection["driver"]

table_description = grass.db_describe(
table=table, database=database, driver=driver
table=table,
database=database,
driver=driver,
)
found = False
# TODO: pythonize this for loop
Expand All @@ -148,15 +165,21 @@ def main():
if found is False:
grass.fatal(
_("Column %s does not exist in layer %s of vector %s")
% (column, layer, aoi_vector)
% (
column,
layer,
aoi_vector,
)
)

# select attribute values with vector_db_select()
grass.message(
_("Print attribute values using %s") % "vector_db_select()"
)
column_values = grass.vector_db_select(
aoi_vector, int(layer), columns=column
aoi_vector,
int(layer),
columns=column,
)
# go over table rows
for key in column_values["values"]:
Expand Down Expand Up @@ -198,7 +221,11 @@ def main():
out_overlay = out_grid
# divide into tiles
kachel_num = grass.parse_command(
"v.db.select", map=out_overlay, columns="cat", flags="c", quiet=True
"v.db.select",
map=out_overlay,
columns="cat",
flags="c",
quiet=True,
)
for kachel in kachel_num:
grass.run_command(
Expand Down

0 comments on commit ca57122

Please sign in to comment.