Commit graph

24 commits

Author SHA1 Message Date
Mike Barnes c44e457fd0 Merge pull request 'Corect code style for main Python module.' (#2) from bignose/ejabberd-auth-mastodon:wip/maintenance/code-style into master
Reviewed-on: #2
2023-01-01 10:50:40 +00:00
Ben Finney 2a7e4fcd6e Remove a statement using a name that is never defined in scope.
The intention may have been to close the “current” database cursor; but
there is no reference to that at this point in the code.
2022-12-19 09:52:20 +11:00
Ben Finney 1ad357ba4a Specify the ‘Exception’ catch-all exception class, not a bare ‘except’.
PEP 8 specifies:

* When catching exceptions, mention specific exceptions whenever possible
  instead of using a bare `except:` clause […]

  A bare `except:` clause will catch `SystemExit` and `KeyboardInterrupt`
  exceptions, making it harder to interrupt a program with Control-C, and
  can disguise other problems. If you want to catch all exceptions that
  signal program errors, use `except Exception:` (bare except is equivalent
  to `except BaseException:`).
2022-12-19 09:50:30 +11:00
Ben Finney 6a4de62467 Remove an assignment to an unused name. 2022-12-19 09:50:30 +11:00
Ben Finney 7118641d78 Use identity operators for comparison to None singleton.
PEP 8 specifies:

* Comparisons to singletons like None should always be done with `is` or
  `is not`, never the equality operators.
2022-12-19 09:49:01 +11:00
Ben Finney 4bed400c7d Use equality operator for comparison to integer value. 2022-12-19 09:49:01 +11:00
Ben Finney a88f298e98 Wrap long block comment lines at 72 columns. 2022-12-19 09:26:13 +11:00
Ben Finney 9325300e39 Wrap long statements across multiple lines.
PEP 8 specifies:

* Limit all lines to a maximum of 79 characters.

* The preferred way of wrapping long lines is by using Python’s implied
  line continuation inside parentheses, brackets and braces. Long lines can
  be broken over multiple lines by wrapping expressions in parentheses.
  These should be used in preference to using a backslash for line
2022-12-19 09:26:03 +11:00
Ben Finney 34ab6489ba Reformat SQL statement for clarity and wrap the long line. 2022-12-19 09:25:58 +11:00
Ben Finney 237abe539a Use whitespace around operators in conformance with PEP 8.
PEP 8 specifies:

* A single space around binary operators (e.g. ‘=’ assignment, ‘%’

* No surrounding space around ‘=’ in keyword argument assignment for a
  function call.
2022-12-19 09:25:54 +11:00
Ben Finney 9a2d05e51f Use ‘# ’ comment leader for block comments.
PEP 8 specifies:

* Each line of a block comment starts with a # and a single space (unless
  it is indented text inside the comment).
2022-12-19 09:25:45 +11:00
Ben Finney 512114517c Remove unused imports. 2022-12-19 09:25:35 +11:00
Ben Finney 3ef1d5daae Use a separate ‘import’ statement for each module/package, grouped.
PEP 8 specifies:

* Imports should usually be on separate lines.

* Imports are always put at the top of the file, just after any module
  comments and docstrings, and before module globals and constants.

* Imports should be grouped in the following order:

  * Standard library imports.
  * Related third party imports.
  * Local application/library specific imports.
2022-12-19 09:25:24 +11:00
Ben Finney e30ab77cf4 Use structural blank lines conformant with PEP 8.
PEP 8 specifies:

* Surround top-level function and class definitions with two blank lines.

* Method definitions inside a class are surrounded by a single blank line.
2022-12-19 09:25:10 +11:00
Ben Finney dc09a6be92 Normalise indentation levels by wrapping at open parenthesis.
PEP 8 specifies:

* Use 4 spaces per indentation level.

* Continuation lines should align wrapped elements either vertically using
  Python’s implicit line joining inside parentheses, brackets and braces,
  or using a hanging indent.
2022-12-19 09:24:54 +11:00
Ben Finney c6c19a1bcf Convert indentation to use U+0020 SPACE characters.
PEP 8 specifies:

* Use 4 spaces per indentation level.

* Spaces (U+0008) are the preferred indentation method.
2022-12-19 09:24:48 +11:00
Ben Finney ebd066b170 Remove trailing whitespace. 2022-12-19 09:24:40 +11:00
Ben Finney de4e2027a1 Specify EditorConfig settings for this code base. 2022-12-19 09:24:31 +11:00
Mike Barnes d232855057 Force lower case on username comparisons
I made some poor assumptions about case-sensitivity in relation to the Mastodon accounts table. Changed now to force username comparison to lower during the select statement, and not trust that we're getting lower case from the ejabberd end, either. This should eliminate the issue of some users being unable to authenticate.
2020-09-21 13:28:38 +00:00
Mike Barnes 7f69c4a177 Gitea doesn't parse XMPP URLs 2020-03-27 16:10:22 +11:00
Mike Barnes 533d8f2767 Link to the beergarden 2020-03-27 14:47:09 +11:00
Mike Barnes 2848a67c44 Apologise for something annoying 2020-03-27 14:36:03 +11:00
Mike Barnes 54b499d24f Add GPL and README 2020-03-27 14:31:08 +11:00
Mike Barnes 3b4e247c62 Initial commit of test implementation 2020-03-27 14:04:57 +11:00