Skip to content

Reorg tool#3644

Merged
alex-jansen merged 2 commits intoschemaorg:mainfrom
pascalfleury:reorg-tool
Sep 27, 2024
Merged

Reorg tool#3644
alex-jansen merged 2 commits intoschemaorg:mainfrom
pascalfleury:reorg-tool

Conversation

@pascalfleury
Copy link
Contributor

Adding a tool to mechanically manage the Turtle files.
Currently the tool can do linting and plain merging.

@alex-jansen alex-jansen merged commit 8111544 into schemaorg:main Sep 27, 2024
@pascalfleury pascalfleury deleted the reorg-tool branch September 27, 2024 10:05
semantic axis.
"""

from collections.abc import Sequence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider only including namespaces, not Classes.

@@ -0,0 +1,101 @@
#!/usr/bin/env python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding the emacs + encoding header.

#!/usr/bin/env python3

-- coding: UTF-8 --

import sys
import argparse

def SchemaOrgGraph():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding type annotations as this is a new file, i.e.

def SchemaOrgGraph() -> rdflib.Graph:

only_in_g1 = g1 - g2
only_in_g2 = g2 - g1
# TODO: print sampled diffs if any.
return len(only_in_g1) == 0 and len(only_in_g2) == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the pythonic way is to use the implicit bool conversion, i.e.

return not only_in_g1 and not only_in_g2

I have no strong opinions on this.

# TODO: print sampled diffs if any.
return len(only_in_subset) == 0

def Lint(args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would pass the arguments explicitly, i.e. output_filename and files so the function can be easily called from Python code/unit-tests.

"""Reformats the file(s) properly."""
def LintOne(filename, output_filename):
logging.info(" - reading file ...")
g = SchemaOrgGraph()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why g and v? Maybe make the variable names longer / more expressive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants