Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/awelzel/remove-codeql-add-…
Browse files Browse the repository at this point in the history
…flake8'

* origin/topic/awelzel/remove-codeql-add-flake8:
  setup.cfg/pre-commit-config: Add flake8 hook and config
  zkg: Fix comparison with True
  zkg: Fix unused variables
  zkg: Imports at top of file
  manager: Bad logging invocatoins
  Remove CodeQL
  • Loading branch information
ckreibich committed Jan 17, 2023
2 parents b218122 + 77bcde4 commit f28a431
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 82 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/codeql.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ repos:
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/pycqa/flake8
rev: 5.0.4 # 6.0.0 requires Python 3.8
hooks:
- id: flake8

exclude: doc/ext/sphinxarg
14 changes: 14 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2.13.0-24 | 2023-01-17 14:29:45 -0800

* setup.cfg/pre-commit-config: Add flake8 hook and config (Arne Welzel, Corelight)

* zkg: Fix comparison with True (Arne Welzel, Corelight)

* zkg: Fix unused variables (Arne Welzel, Corelight)

* zkg: Imports at top of file (Arne Welzel, Corelight)

* manager: Bad logging invocatoins (Arne Welzel, Corelight)

* Remove CodeQL (Christian Kreibich, Corelight)

2.13.0-17 | 2023-01-10 12:54:54 -0800

* Replace manual nested loops with set operation. (Benjamin Bannier, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.0-17
2.13.0-24
2 changes: 1 addition & 1 deletion doc/man/zkg.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "ZKG" "1" "Jan 10, 2023" "2.13.0-17" "Zeek Package Manager"
.TH "ZKG" "1" "Jan 17, 2023" "2.13.0-24" "Zeek Package Manager"
.SH NAME
zkg \- Zeek Package Manager
.sp
Expand Down
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
[bdist_wheel]
universal = 1

[flake8]
max_line_length = 100
# E203: whitespace before ':' (black / flake8 disagreement)
# W503: line break before binary operator (black / flake8 disagreement)
ignore=E203,W503
# E402: module level import not at top of file
# F405: may be undefined, or defined from star imports
# F403: from .manager import *' used; unable to detect undefined names
per-file-ignores = */__init__.py: F405,F403,E402
2 changes: 1 addition & 1 deletion zeekpkg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import logging

__version__ = "2.13.0-17"
__version__ = "2.13.0-24"
__all__ = ["manager", "package", "source", "template", "uservar"]

LOG = logging.getLogger(__name__)
Expand Down
16 changes: 8 additions & 8 deletions zeekpkg/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,19 @@ def _write_plugin_magic(self, ipkg):
os.rename(magic_path_disabled, magic_path)
except OSError as exception:
LOG.warning(
"could not enable plugin: %s: %s".format(
type(exception).__name__, exception
)
"could not enable plugin: %s %s",
type(exception).__name__,
exception,
)
else:
if os.path.exists(magic_path):
try:
os.rename(magic_path, magic_path_disabled)
except OSError as exception:
LOG.warning(
"could not disable plugin: %s: %s".format(
type(exception).__name__, exception
)
"could not disable plugin: %s %s",
type(exception).__name__,
exception,
)

def _read_manifest(self):
Expand Down Expand Up @@ -1257,8 +1257,8 @@ def remove(self, pkg_path):
try:
LOG.debug("removing link %s", link)
os.unlink(link)
except os.error as excpt:
LOG.warn("cannot remove link for %s", exec)
except os.error as err:
LOG.warn("cannot remove link for %s", err)

del self.installed_pkgs[pkg_to_remove.name]
self._write_manifest()
Expand Down
58 changes: 28 additions & 30 deletions zkg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ try:
except ImportError:
pass

from zeekpkg._util import (
delete_path,
make_dir,
make_symlink,
find_program,
read_zeek_config_line,
std_encoding,
)
from zeekpkg.package import (
TRACKING_METHOD_VERSION,
)
from zeekpkg.template import (
LoadError,
Template,
)
from zeekpkg.uservar import (
UserVar,
)

import zeekpkg

# For Zeek-bundled installation, prepend the Python path of the Zeek
# installation. This ensures we find the matching zeekpkg module
# first, avoiding potential conflicts with installations elsewhere on
Expand Down Expand Up @@ -85,27 +106,6 @@ ZKG_DEFAULT_SOURCE = "https://github.com/zeek/packages"
# The default package template
ZKG_DEFAULT_TEMPLATE = "https://github.com/zeek/package-template"

from zeekpkg._util import (
delete_path,
make_dir,
make_symlink,
find_program,
read_zeek_config_line,
std_encoding,
)
from zeekpkg.package import (
TRACKING_METHOD_VERSION,
)
from zeekpkg.template import (
LoadError,
Template,
)
from zeekpkg.uservar import (
UserVar,
)

import zeekpkg


def confirmation_prompt(prompt, default_to_yes=True):
yes = {"y", "ye", "yes"}
Expand Down Expand Up @@ -329,15 +329,15 @@ def create_config(args, configfile):
def active_git_branch(path):
try:
repo = git.Repo(path)
except git.exc.NoSuchPathError as error:
except git.exc.NoSuchPathError:
return None

if not repo.working_tree_dir:
return None

try:
rval = repo.active_branch
except TypeError as error:
except TypeError:
# return detached commit
rval = repo.head.commit

Expand All @@ -359,7 +359,7 @@ def is_local_git_repo(git_url):
# accessible, (2) it's not the root directory of a git repo.
git.Repo(git_url)
return True
except (git.exc.InvalidGitRepositoryError, git.exc.NoSuchPathError) as error:
except (git.exc.InvalidGitRepositoryError, git.exc.NoSuchPathError):
return False


Expand All @@ -368,7 +368,7 @@ def is_local_git_repo_dirty(git_url):
return False
try:
repo = git.Repo(git_url)
except git.exc.NoSuchPathError as error:
except git.exc.NoSuchPathError:
return False

return repo.is_dirty(untracked_files=True)
Expand Down Expand Up @@ -1536,11 +1536,9 @@ def cmd_upgrade(manager, args, config, configfile):

for info, next_version, _ in outdated_packages:
name = info.package.qualified_name()
bdir = name

if not manager.match_source_packages(name):
name = info.package.git_url
bdir = zeekpkg.package.name_from_path(name)

ipkg = manager.find_installed_package(name)
modifications = manager.modified_config_files(ipkg)
Expand Down Expand Up @@ -1918,7 +1916,7 @@ def cmd_info(manager, args, config, configfile):

for name in package_names:
info = manager.info(
name, version=args.version, prefer_installed=(args.nolocal != True)
name, version=args.version, prefer_installed=(not args.nolocal)
)

if info.package:
Expand Down Expand Up @@ -1968,7 +1966,7 @@ def cmd_info(manager, args, config, configfile):
print(f'\tmetadata (from version "{info.metadata_version}"):')

if len(info.metadata) == 0:
if args.json != True:
if not args.json:
print("\t\t<empty metadata file>")
else:
if args.json:
Expand All @@ -1987,7 +1985,7 @@ def cmd_info(manager, args, config, configfile):
# Skip the version that was already processed
if vers != info.metadata_version:
info2 = manager.info(
name, vers, prefer_installed=(args.nolocal != True)
name, vers, prefer_installed=(not args.nolocal)
)
pkginfo[name]["metadata"][info2.metadata_version] = dict()
if info2.metadata_file:
Expand Down

0 comments on commit f28a431

Please sign in to comment.